#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ calculate_add_time(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ calculate_mul_time(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int iterations = 10;
  if (argc >= 2) {
    iterations = atoi(argv[1]);
  }
  uint64_t values[iterations];
  if (argc >= 3 && strcmp(argv[2], "add")) {
    calculate_add_time(iterations, values);
  } else {
    calculate_mul_time(iterations, values);
  }
  for (int i = 0; i < iterations; i++) {
    printf("%lu\n", values[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11e7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe39(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11e7 <main+0x97>
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%edi
call   1040 <calculate_add_time@plt>
jmp    11f3 <main+0xa3>
mov    -0x38(%rbp),%rsi
mov    -0x14(%rbp),%edi
call   1060 <calculate_mul_time@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    122b <main+0xdb>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11fa <main+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11b9 <main+0x69>
mov    %rsi,%r15
mov    %edi,%r12d
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    %eax,%eax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmp    $0x2,%r12d
je     11c9 <main+0x79>
mov    0x10(%r15),%rdi
lea    0xe63(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c9 <main+0x79>
mov    %r14d,%edi
mov    %r13,%rsi
call   1040 <calculate_add_time@plt>
test   %r14d,%r14d
jg     11d9 <main+0x89>
jmp    1206 <main+0xb6>
mov    %rsp,%r13
add    $0xffffffffffffffd0,%r13
mov    %r13,%rsp
mov    $0xa,%r14d
mov    %r14d,%edi
mov    %r13,%rsi
call   1060 <calculate_mul_time@plt>
test   %r14d,%r14d
jle    1206 <main+0xb6>
mov    %r14d,%r15d
xor    %ebx,%ebx
lea    0xe1f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11f0 <main+0xa0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"add\00"
@.str.1 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %7
%21 = alloca i32, i64 %19
store i64 %19, i64* %8
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 3
br i1 %23, label %24, label %33
24: ; preds = %17
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* %6
%32 = call i32 @calculate_add_time(i32 %31, i32* %21)
br label %36
33: ; preds = %24, %17
%34 = load i32, i32* %6
%35 = call i32 @calculate_mul_time(i32 %34, i32* %21)
br label %36
36: ; preds = %33, %30
store i32 0, i32* %9
br label %37
37: ; preds = %47, %36
%38 = load i32, i32* %9
%39 = load i32, i32* %6
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %50
41: ; preds = %37
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %21, i64 %43
%45 = load i32, i32* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %41
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %37
50: ; preds = %37
store i32 0, i32* %3
%51 = load i8*, i8** %7
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [4 x i8] c"add\00"
@.str.1 = [5 x i8] c"%lu\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = alloca [10 x i32]
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = zext i32 %10 to i64
%12 = alloca i32, i64 %11
%13 = icmp eq i32 %0, 2
br i1 %13, label %21, label %14
14: ; preds = %7
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = call i32 @calculate_add_time(i32 %10, i32* %12)
br label %25
21: ; preds = %4, %14, %7
%22 = phi i32* [ %6, %4 ], [ %12, %14 ], [ %12, %7 ]
%23 = phi i32 [ 10, %4 ], [ %10, %14 ], [ %10, %7 ]
%24 = call i32 @calculate_mul_time(i32 %23, i32* %22)
br label %25
25: ; preds = %21, %19
%26 = phi i32* [ %22, %21 ], [ %12, %19 ]
%27 = phi i32 [ %23, %21 ], [ %10, %19 ]
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = zext i32 %27 to i64
br label %32
31: ; preds = %32, %25
ret i32 0
32: ; preds = %29, %32
%33 = phi i64 [ 0, %29 ], [ %37, %32 ]
%34 = getelementptr inbounds i32, i32* %26, i64 %33
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %33, 1
%38 = icmp eq i64 %37, %30
br i1 %38, label %31, label %32
}