int main(int argc, char *argv[]) {
  char *str, *p;
  unsigned int secs = 30;
  unsigned int timer;
  int block = 100;
  if (argc == 2) {
    if (strcmp("-h", argv[1]) == 0) {
      help_function(argv[0]);
      return 0;
    } else {
      block = strtol(argv[1], &p, 10);
    }
  }
  printf("PID = %d\n", getpid());
  for (int i = 0; i < block; i++) {
    str = (char *)malloc(1024);
  }
  strcpy(str, "simple_test");
  printf("Reserving %d Kb of memory\n", block);
  printf("Value of String = %s\n", str);
  printf("Address = %u\n", str);
  timer = time(0) + secs;
  printf("Waiting for %d seconds\n", secs);
  while (time(0) < timer)
    ;
  free(str);
  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   $0x1e,-0x24(%rbp)
movl   $0x64,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1213 <main+0x83>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe33(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11f5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   10b0 <help_function@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e5 <main+0x155>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,-0x2c(%rbp)
jmp    1213 <main+0x83>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1259 <main+0xc9>
mov    $0x400,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1231 <main+0xa1>
mov    -0x18(%rbp),%rdi
lea    0xda9(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x2c(%rbp),%esi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1090 <time@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%esi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1090 <time@plt>
cmp    -0x28(%rbp),%eax
jae    12d5 <main+0x145>
jmp    12be <main+0x12e>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x64,%r14d
cmp    $0x2,%edi
jne    11c6 <main+0x46>
mov    %rsi,%rbx
mov    0x8(%rsi),%rbp
lea    0xe5f(%rip),%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1287 <main+0x107>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r14d,%r14d
jle    1204 <main+0x84>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x400,%edi
call   1090 <malloc@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x70>
mov    %rax,%rbx
jmp    1204 <main+0x84>
movabs $0x745f656c706d6973,%rax
65 5f 74
mov    %rax,(%rbx)
movl   $0x747365,0x8(%rbx)
lea    0xdfa(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe04(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe09(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <time@plt>
mov    %eax,%ebp
add    $0x1e,%ebp
lea    0xdf8(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1050 <printf@plt>
nopl   0x0(%rax)
xor    %edi,%edi
xor    %eax,%eax
call   1080 <time@plt>
cmp    %ebp,%eax
jb     1270 <main+0xf0>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1291 <main+0x111>
mov    (%rbx),%rdi
xor    %eax,%eax
call   10a0 <help_function@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [10 x i8] c"PID = %d\0A\00"
@.str.2 = [12 x i8] c"simple_test\00"
@.str.3 = [27 x i8] c"Reserving %d Kb of memory\0A\00"
@.str.4 = [22 x i8] c"Value of String = %s\0A\00"
@.str.5 = [14 x i8] c"Address = %u\0A\00"
@.str.6 = [24 x i8] c"Waiting for %d seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 30, i32* %8
store i32 100, i32* %10
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %32
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) bitcast (i32 (...)* @help_function to i32 (i8*, ...)*)(i8* %23)
store i32 0, i32* %3
br label %65
25: ; preds = %14
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strtol(i8* %28, i8** %7, i32 10)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %10
br label %31
31: ; preds = %25
br label %32
32: ; preds = %31, %2
%33 = call i32 (...) @getpid()
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %33)
store i32 0, i32* %11
br label %35
35: ; preds = %41, %32
%36 = load i32, i32* %11
%37 = load i32, i32* %10
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = call i8* @malloc(i64 1024)
store i8* %40, i8** %6
br label %41
41: ; preds = %39
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %35
44: ; preds = %35
%45 = load i8*, i8** %6
%46 = call i8* @strcpy(i8* %45, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %10
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %47)
%49 = load i8*, i8** %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %49)
%51 = load i8*, i8** %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %51)
%53 = call i32 (i32, ...) bitcast (i32 (...)* @time to i32 (i32, ...)*)(i32 0)
%54 = load i32, i32* %8
%55 = add i32 %53, %54
store i32 %55, i32* %9
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %56)
br label %58
58: ; preds = %62, %44
%59 = call i32 (i32, ...) bitcast (i32 (...)* @time to i32 (i32, ...)*)(i32 0)
%60 = load i32, i32* %9
%61 = icmp ult i32 %59, %60
br i1 %61, label %62, label %63
62: ; preds = %58
br label %58
63: ; preds = %58
%64 = load i8*, i8** %6
store i32 0, i32* %3
br label %65
65: ; preds = %63, %20
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [10 x i8] c"PID = %d\0A\00"
@.str.2 = [12 x i8] c"simple_test\00"
@.str.3 = [27 x i8] c"Reserving %d Kb of memory\0A\00"
@.str.4 = [22 x i8] c"Value of String = %s\0A\00"
@.str.5 = [14 x i8] c"Address = %u\0A\00"
@.str.6 = [24 x i8] c"Waiting for %d seconds\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @help_function to i32 (i8*, ...)*)(i8* %12)
br label %39
14: ; preds = %6
%15 = call i64 @strtol(i8* %8, i8** %3, i32 10)
%16 = trunc i64 %15 to i32
br label %17
17: ; preds = %14, %2
%18 = phi i32 [ %16, %14 ], [ 100, %2 ]
%19 = tail call i32 (...) @getpid()
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = icmp sgt i32 %18, 0
br i1 %21, label %30, label %22
22: ; preds = %30, %17
%23 = phi i8* [ undef, %17 ], [ %32, %30 ]
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %23, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 12, i1 false)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%27 = tail call i32 (i32, ...) bitcast (i32 (...)* @time to i32 (i32, ...)*)(i32 0)
%28 = add i32 %27, 30
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 30)
br label %35
30: ; preds = %17, %30
%31 = phi i32 [ %33, %30 ], [ 0, %17 ]
%32 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%33 = add nuw nsw i32 %31, 1
%34 = icmp eq i32 %33, %18
br i1 %34, label %22, label %30
35: ; preds = %35, %22
%36 = tail call i32 (i32, ...) bitcast (i32 (...)* @time to i32 (i32, ...)*)(i32 0)
%37 = icmp ult i32 %36, %28
br i1 %37, label %35, label %38
38: ; preds = %35
tail call void @free(i8* %23)
br label %39
39: ; preds = %38, %11
ret i32 0
}