#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 */
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
typedef unsigned long long int64_t;

/* Variables and functions */
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ sleep(int);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  int argc_count = 0;
  while (1) {
    for (size_t j = 0; j < strlen(argv[0]); j++) {
      argv[argc_count][j] = ' ';
    }
    ++argc_count;
    if (argc_count == argc)
      break;
  }
  printf("pid is %ld\n", getpid());
  sleep(108);
  int64_t i;
  struct timeval start;
  gettimeofday(&start, NULL);
  printf("%ld, %ld", start.tv_sec, start.tv_usec);
  for (i = 0; i < 10000000ULL; i++) {
  }
  gettimeofday(&start, NULL);
  printf("%ld, %ld", start.tv_sec, start.tv_usec);
  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   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jae    11be <main+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1175 <main+0x25>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11d8 <main+0x88>
jmp    11dd <main+0x8d>
jmp    116d <main+0x1d>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x6c,%edi
call   1070 <sleep@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0x989680,-0x28(%rbp)
jae    124b <main+0xfb>
jmp    123a <main+0xea>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1227 <main+0xd7>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    (%rsi),%r13
xor    %r12d,%r12d
jmp    1179 <main+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r15,%r12
je     11ae <main+0x5e>
cmpb   $0x0,0x0(%r13)
je     1170 <main+0x20>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%r12,8),%rax
movb   $0x20,(%rax,%rbx,1)
add    $0x1,%rbx
mov    (%r14),%r13
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %rax,%rbx
jb     1190 <main+0x40>
jmp    1170 <main+0x20>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe44(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x6c,%edi
call   1070 <sleep@plt>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
lea    0xe1f(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"pid is %ld\0A\00"
@.str.1 = [9 x i8] c"%ld, %ld\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %10
10: ; preds = %2, %36
store i64 0, i64* %7
br label %11
11: ; preds = %26, %10
%12 = load i64, i64* %7
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
%17 = icmp ult i64 %12, %16
br i1 %17, label %18, label %29
18: ; preds = %11
%19 = load i8**, i8*** %5
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i64, i64* %7
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 32, i8* %25
br label %26
26: ; preds = %18
%27 = load i64, i64* %7
%28 = add i64 %27, 1
store i64 %28, i64* %7
br label %11
29: ; preds = %11
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %29
br label %37
36: ; preds = %29
br label %10
37: ; preds = %35
%38 = call i32 (...) @getpid()
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = call i32 @sleep(i32 108)
%41 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %45)
store i64 0, i64* %8
br label %47
47: ; preds = %51, %37
%48 = load i64, i64* %8
%49 = icmp ult i64 %48, 10000000
br i1 %49, label %50, label %54
50: ; preds = %47
br label %51
51: ; preds = %50
%52 = load i64, i64* %8
%53 = add i64 %52, 1
store i64 %53, i64* %8
br label %47
54: ; preds = %47
%55 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%57 = load i32, i32* %56
%58 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %57, i32 %59)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [12 x i8] c"pid is %ld\0A\00"
@.str.1 = [9 x i8] c"%ld, %ld\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = zext i32 %0 to i64
%5 = load i8*, i8** %1
br label %6
6: ; preds = %13, %2
%7 = phi i8* [ %14, %13 ], [ %5, %2 ]
%8 = phi i64 [ %15, %13 ], [ 0, %2 ]
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 %8
br label %17
13: ; preds = %17, %6
%14 = phi i8* [ %7, %6 ], [ %22, %17 ]
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %4
br i1 %16, label %25, label %6
17: ; preds = %11, %17
%18 = phi i64 [ 0, %11 ], [ %21, %17 ]
%19 = load i8*, i8** %12
%20 = getelementptr inbounds i8, i8* %19, i64 %18
store i8 32, i8* %20
%21 = add nuw i64 %18, 1
%22 = load i8*, i8** %1
%23 = tail call i64 @strlen(i8* dereferenceable(1) %22)
%24 = icmp ult i64 %21, %23
br i1 %24, label %17, label %13
25: ; preds = %13
%26 = tail call i32 (...) @getpid()
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = tail call i32 @sleep(i32 108)
%29 = bitcast %struct.timeval* %3 to i8*
%30 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%34 = load i32, i32* %33
%35 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %34)
%36 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%37 = load i32, i32* %31
%38 = load i32, i32* %33
%39 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38)
ret i32 0
}