#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ icount_start(unsigned long);
int /*<<< orphan*/ icount_stop();
int /*<<< orphan*/ icount_total();
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int i;
  int sum;
  unsigned long ttl = 0ul;
  if (argc == 2)
    ttl = strtoul(argv[1], NULL, 10);
  icount_start(ttl);
  for (i = 0; i < 1; i++)
    sum += i;
  icount_stop();
  printf("Total instruction count: %lu\n", icount_total());
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11a2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <icount_start@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    11d3 <main+0x73>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <main+0x52>
mov    $0x0,%al
call   1060 <icount_stop@plt>
mov    $0x0,%al
call   1050 <icount_total@plt>
mov    %eax,%esi
lea    0xe16(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    117b <main+0x1b>
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtoul@plt>
mov    %rax,%rdi
jmp    117d <main+0x1d>
xor    %edi,%edi
call   1030 <icount_start@plt>
xor    %eax,%eax
call   1060 <icount_stop@plt>
xor    %eax,%eax
call   1050 <icount_total@plt>
lea    0xe69(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Total instruction count: %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strtoul(i8* %14, i32* null, i32 10)
store i64 %15, i64* %8
br label %16
16: ; preds = %11, %2
%17 = load i64, i64* %8
%18 = call i32 @icount_start(i64 %17)
store i32 0, i32* %6
br label %19
19: ; preds = %26, %16
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = add nsw i32 %24, %23
store i32 %25, i32* %7
br label %26
26: ; preds = %22
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %19
29: ; preds = %19
%30 = call i32 (...) @icount_stop()
%31 = call i32 (...) @icount_total()
%32 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [30 x i8] c"Total instruction count: %lu\0A\00"
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 i64 @strtoul(i8* nocapture %6, i32* null, i32 10)
br label %8
8: ; preds = %4, %2
%9 = phi i64 [ %7, %4 ], [ 0, %2 ]
%10 = tail call i32 @icount_start(i64 %9)
%11 = tail call i32 (...) @icount_stop()
%12 = tail call i32 (...) @icount_total()
%13 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @exit(i32 0)
unreachable
}