#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 timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_PROCESS_CPUTIME_ID;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int main(int argc, char *argv[]) {
  int i = 0;
  char input[255];
  struct timespec start, stop;
  double result;
  memset(input, 0, 255);
  printf("\n\nThird version -> lang==c\n");
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
  for (i = 1; i < argc; i++) {
    strcat(input, argv[i]);
    strcat(input, " ");
  }
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &stop);
  result =
      (stop.tv_sec - start.tv_sec) * 1e6 + (stop.tv_nsec - start.tv_nsec) / 1e3;
  printf("Result in micro seconds: %d\n", (int)result);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1050 <memset@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x128(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f2 <main+0xa2>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <strcat@plt>
lea    -0x120(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x5d>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x130(%rbp),%eax
sub    -0x128(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x12c(%rbp),%eax
sub    -0x124(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xdd9(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xdc5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
cvttsd2si -0x138(%rbp),%esi
ff
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0xff,%edx
call   1060 <memset@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4e(%rip),%r15
mov    (%r15),%edi
lea    0x8(%rsp),%rsi
call   1040 <clock_gettime@plt>
cmp    $0x2,%ebp
jl     11e0 <main+0x80>
mov    %ebp,%r13d
mov    $0x1,%ebx
lea    0x10(%rsp),%rbp
lea    0xe50(%rip),%r14
mov    (%r12,%rbx,8),%rsi
mov    %rbp,%rdi
call   1070 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <main+0x60>
mov    (%r15),%edi
mov    %rsp,%rsi
call   1040 <clock_gettime@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
cvtsi2sd %eax,%xmm0
sub    0xc(%rsp),%ecx
cvtsi2sd %ecx,%xmm1
divsd  0xdf6(%rip),%xmm1
mulsd  0xdf6(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@.str = [28 x i8] c"\0A\0AThird version -> lang==c\0A\00"
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [29 x i8] c"Result in micro seconds: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca %struct.timespec
%9 = alloca %struct.timespec
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%11 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 255)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%15 = call i32 @clock_gettime(i32 %14, %struct.timespec* %8)
store i32 1, i32* %6
br label %16
16: ; preds = %30, %2
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %33
20: ; preds = %16
%21 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strcat(i8* %21, i8* %26)
%28 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %20
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %16
33: ; preds = %16
%34 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%35 = call i32 @clock_gettime(i32 %34, %struct.timespec* %9)
%36 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%39 = load i32, i32* %38
%40 = sub nsw i32 %37, %39
%41 = sitofp i32 %40 to double
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
%45 = load i32, i32* %44
%46 = sub nsw i32 %43, %45
%47 = sitofp i32 %46 to double
%48 = fdiv double %47, 1.000000e+03
%49 = call double @llvm.fmuladd.f64(double %41, double 1.000000e+06, double %48)
store double %49, double* %10
%50 = load double, double* %10
%51 = fptosi double %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [29 x i8] c"Result in micro seconds: %d\0A\00"
@str = [27 x i8] c"\0A\0AThird version -> lang==c\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.timespec* %4 to i8*
%8 = bitcast %struct.timespec* %5 to i8*
%9 = call i32 @memset(i8* %6, i32 0, i32 255)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %4)
%13 = icmp sgt i32 %0, 1
br i1 %13, label %14, label %24
14: ; preds = %2
%15 = zext i32 %0 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 1, %14 ], [ %22, %16 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @strcat(i8* %6, i8* %19)
%21 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, %15
br i1 %23, label %24, label %16
24: ; preds = %16, %2
%25 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%26 = call i32 @clock_gettime(i32 %25, %struct.timespec* %5)
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%30 = load i32, i32* %29
%31 = sub nsw i32 %28, %30
%32 = sitofp i32 %31 to double
%33 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%36 = load i32, i32* %35
%37 = sub nsw i32 %34, %36
%38 = sitofp i32 %37 to double
%39 = fdiv double %38, 1.000000e+03
%40 = call double @llvm.fmuladd.f64(double %32, double 1.000000e+06, double %39)
%41 = fptosi double %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = call i32 @exit(i32 0)
unreachable
}