#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ fun();
scalar_t__ malloc(int);
int main(int argc, char **argv) {
  int *n, *m, res;
  int repeats = 1;
  if (argc == 2) {
    repeats = atoi(argv[1]);
  }
  n = (int *)malloc(sizeof(int));
  *n = 5;
  free(n);
  while (repeats--) {
    for (int i = 0; i < 1000000; ++i)
      ;
    fun();
  }
  m = (int *)malloc(sizeof(int));
  *m = 5;
  free(m);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
je     11df <main+0x9f>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf4240,-0x2c(%rbp)
jge    11d3 <main+0x93>
jmp    11c5 <main+0x85>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b3 <main+0x73>
mov    $0x0,%al
call   1040 <fun@plt>
jmp    1198 <main+0x58>
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    1156 <main+0x16>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    $0x4,%edi
call   1050 <malloc@plt>
movl   $0x5,(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     118c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <fun@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x40>
mov    $0x4,%edi
call   1050 <malloc@plt>
movl   $0x5,(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %9
br label %18
18: ; preds = %13, %2
%19 = call i64 @malloc(i32 4)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %6
%21 = load i32*, i32** %6
store i32 5, i32* %21
%22 = load i32*, i32** %6
%23 = call i32 @free(i32* %22)
br label %24
24: ; preds = %36, %18
%25 = load i32, i32* %9
%26 = add nsw i32 %25, -1
store i32 %26, i32* %9
%27 = icmp ne i32 %25, 0
br i1 %27, label %28, label %38
28: ; preds = %24
store i32 0, i32* %10
br label %29
29: ; preds = %33, %28
%30 = load i32, i32* %10
%31 = icmp slt i32 %30, 1000000
br i1 %31, label %32, label %36
32: ; preds = %29
br label %33
33: ; preds = %32
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %29
36: ; preds = %29
%37 = call i32 (...) @fun()
br label %24
38: ; preds = %24
%39 = call i64 @malloc(i32 4)
%40 = inttoptr i64 %39 to i32*
store i32* %40, i32** %7
%41 = load i32*, i32** %7
store i32 5, i32* %41
%42 = load i32*, i32** %7
%43 = call i32 @free(i32* %42)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 1, %2 ]
%10 = tail call i64 @malloc(i32 4)
%11 = inttoptr i64 %10 to i32*
store i32 5, i32* %11
%12 = tail call i32 @free(i32* %11)
%13 = icmp eq i32 %9, 0
br i1 %13, label %19, label %14
14: ; preds = %8, %14
%15 = phi i32 [ %16, %14 ], [ %9, %8 ]
%16 = add nsw i32 %15, -1
%17 = tail call i32 (...) @fun()
%18 = icmp eq i32 %16, 0
br i1 %18, label %19, label %14
19: ; preds = %14, %8
%20 = tail call i64 @malloc(i32 4)
%21 = inttoptr i64 %20 to i32*
store i32 5, i32* %21
%22 = tail call i32 @free(i32* %21)
ret i32 0
}