1 //===-- main.cpp ------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include <cstdlib> 10 #include <string> 11 #include <fstream> 12 #include <iostream> 13 14 int 15 product (int x, int y) 16 { 17 int result = x * y; 18 return result; 19 } 20 21 int 22 sum (int a, int b) 23 { 24 int result = a + b; 25 return result; 26 } 27 28 int 29 strange_max (int m, int n) 30 { 31 if (m > n) 32 return m; 33 else if (n > m) 34 return n; 35 else 36 return 0; 37 } 38 39 int 40 foo (int i, int j) 41 { 42 if (strange_max (i, j) == i) 43 return product (i, j); 44 else if (strange_max (i, j) == j) 45 return sum (i, j); 46 else 47 return product (sum (i, i), sum (j, j)); 48 } 49 50 int 51 main(int argc, char const *argv[]) 52 { 53 54 int array[3]; 55 56 array[0] = foo (1238, 78392); 57 array[1] = foo (379265, 23674); 58 array[2] = foo (872934, 234); 59 60 return 0; 61 } 62