#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 *);
scalar_t__ malloc(int);
int main(int argc, char **argv) {
  int i, a;
  int *t;
  for (i = 0; i < atoi(argv[1]); i++) {
    t = (int *)malloc(sizeof(int));
    *t = 0;
    a = *t;
    free(t);
  }
  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   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11a5 <main+0x75>
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    1178 <main+0x48>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x4,%edi
call   1040 <malloc@plt>
movl   $0x0,(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
add    $0x1,%ebp
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
cmp    %eax,%ebp
jl     1150 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* %6
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
%15 = icmp slt i32 %10, %14
br i1 %15, label %16, label %27
16: ; preds = %9
%17 = call i64 @malloc(i32 4)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %8
%19 = load i32*, i32** %8
store i32 0, i32* %19
%20 = load i32*, i32** %8
%21 = load i32, i32* %20
store i32 %21, i32* %7
%22 = load i32*, i32** %8
%23 = call i32 @free(i32* %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %9
27: ; preds = %9
ret i32 0
}

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