#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 {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int WEXITSTATUS(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  struct timeval before;
  struct timeval after;
  int ret;
  double usecs = 0.0f;
  char *command;
  int i;
  int size = 0;
  char buffer[2048];
  for (i = 1; i < argc; ++i)
    size += strlen(argv[i]) + 1;
  ++size;
  command = malloc(size);
  memset(command, 0, size);
  for (i = 1; i < argc; ++i) {
    strcat(command, argv[i]);
    strcat(command, " ");
  }
  gettimeofday(&before, 0);
  fp = popen(command, "r");
  if (fp == NULL) {
    exit(-1);
  }
  memset(buffer, 0, sizeof(buffer));
  while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) {
    printf("%s", buffer);
  }
  ret = pclose(fp);
  gettimeofday(&after, 0);
  usecs = (double)(after.tv_sec) * 1000000.0f + (double)(after.tv_usec) -
          (double)(before.tv_sec) * 1000000.0f - (double)(before.tv_usec);
  printf("%%utime%% %f\n", usecs);
  return WEXITSTATUS(ret);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121b <main+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
movslq -0x58(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11df <main+0x2f>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%edx
xor    %esi,%esi
call   1070 <memset@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1284 <main+0xd4>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10c0 <strcat@plt>
mov    -0x50(%rbp),%rdi
lea    0xd97(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1245 <main+0x95>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x50(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   10b0 <popen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12b8 <main+0x108>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0x860(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1070 <memset@plt>
lea    -0x860(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x7ff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1304 <main+0x154>
lea    -0x860(%rbp),%rsi
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12cb <main+0x11b>
mov    -0x18(%rbp),%rdi
call   1050 <pclose@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
cvtsi2sdq -0x30(%rbp),%xmm1
cvtsi2sdq -0x38(%rbp),%xmm0
movsd  0xcd1(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
cvtsi2sdq -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xca4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xc90(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x820,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     11fa <main+0x4a>
mov    %r14d,%r12d
xor    %ebx,%ebx
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rdi
call   1030 <strlen@plt>
add    %eax,%ebx
add    $0x1,%ebx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11e0 <main+0x30>
add    $0x1,%ebx
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1070 <memset@plt>
cmp    $0x2,%r14d
jl     1250 <main+0xa0>
mov    %r14d,%r12d
mov    $0x1,%ebx
lea    0xde3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,8),%rsi
mov    %rbp,%rdi
call   10c0 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10c0 <strcat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1230 <main+0x80>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    0xda7(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <popen@plt>
test   %rax,%rax
je     1348 <main+0x198>
mov    %rax,%rbx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1070 <memset@plt>
mov    %rbp,%rdi
mov    $0x7ff,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     12d2 <main+0x122>
lea    0xd65(%rip),%r14
lea    0x20(%rsp),%rbp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    $0x7ff,%esi
mov    %rbx,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    12b0 <main+0x100>
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
cvtsi2sdq 0x8(%rsp),%xmm0
cvtsi2sdq (%rsp),%xmm1
movsd  0xd05(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x18(%rsp),%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
lea    0xce5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %ebx,%edi
call   10a0 <WEXITSTATUS@plt>
add    $0x820,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [14 x i8] c"%%utime%% %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca i32
%10 = alloca double
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0.000000e+00, double* %10
store i32 0, i32* %13
store i32 1, i32* %12
br label %15
15: ; preds = %31, %2
%16 = load i32, i32* %12
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %12
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %25, 1
%27 = load i32, i32* %13
%28 = sext i32 %27 to i64
%29 = add nsw i64 %28, %26
%30 = trunc i64 %29 to i32
store i32 %30, i32* %13
br label %31
31: ; preds = %19
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
br label %15
34: ; preds = %15
%35 = load i32, i32* %13
%36 = add nsw i32 %35, 1
store i32 %36, i32* %13
%37 = load i32, i32* %13
%38 = call i8* @malloc(i32 %37)
store i8* %38, i8** %11
%39 = load i8*, i8** %11
%40 = load i32, i32* %13
%41 = call i32 @memset(i8* %39, i32 0, i32 %40)
store i32 1, i32* %12
br label %42
42: ; preds = %56, %34
%43 = load i32, i32* %12
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %59
46: ; preds = %42
%47 = load i8*, i8** %11
%48 = load i8**, i8*** %5
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 @strcat(i8* %47, i8* %52)
%54 = load i8*, i8** %11
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %46
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %42
59: ; preds = %42
%60 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%61 = load i8*, i8** %11
%62 = call i32* @popen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %62, i32** %6
%63 = load i32*, i32** %6
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %67
65: ; preds = %59
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %59
%68 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%69 = call i32 @memset(i8* %68, i32 0, i32 2048)
br label %70
70: ; preds = %75, %67
%71 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%72 = load i32*, i32** %6
%73 = call i32* @fgets(i8* %71, i32 2047, i32* %72)
%74 = icmp ne i32* %73, null
br i1 %74, label %75, label %78
75: ; preds = %70
%76 = getelementptr inbounds [2048 x i8], [2048 x i8]* %14, i64 0, i64 0
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %76)
br label %70
78: ; preds = %70
%79 = load i32*, i32** %6
%80 = call i32 @pclose(i32* %79)
store i32 %80, i32* %9
%81 = call i32 @gettimeofday(%struct.timeval* %8, i32 0)
%82 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%83 = load i64, i64* %82
%84 = sitofp i64 %83 to double
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%86 = load i64, i64* %85
%87 = sitofp i64 %86 to double
%88 = call double @llvm.fmuladd.f64(double %84, double 1.000000e+06, double %87)
%89 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%90 = load i64, i64* %89
%91 = sitofp i64 %90 to double
%92 = fneg double %91
%93 = call double @llvm.fmuladd.f64(double %92, double 1.000000e+06, double %88)
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%95 = load i64, i64* %94
%96 = sitofp i64 %95 to double
%97 = fsub double %93, %96
store double %97, double* %10
%98 = load double, double* %10
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %98)
%100 = load i32, i32* %9
%101 = call i32 @WEXITSTATUS(i32 %100)
ret i32 %101
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [14 x i8] c"%%utime%% %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca [2048 x i8]
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 1, %10 ], [ %21, %12 ]
%14 = phi i32 [ 0, %10 ], [ %20, %12 ]
%15 = getelementptr inbounds i8*, i8** %1, i64 %13
%16 = load i8*, i8** %15
%17 = tail call i64 @strlen(i8* dereferenceable(1) %16)
%18 = trunc i64 %17 to i32
%19 = add i32 %14, 1
%20 = add i32 %19, %18
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %11
br i1 %22, label %23, label %12
23: ; preds = %12
%24 = add i32 %20, 1
br label %25
25: ; preds = %23, %2
%26 = phi i32 [ 1, %2 ], [ %24, %23 ]
%27 = tail call i8* @malloc(i32 %26)
%28 = tail call i32 @memset(i8* %27, i32 0, i32 %26)
br i1 %9, label %29, label %39
29: ; preds = %25
%30 = zext i32 %0 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 1, %29 ], [ %37, %31 ]
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 @strcat(i8* %27, i8* %34)
%36 = tail call i32 @strcat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = add nuw nsw i64 %32, 1
%38 = icmp eq i64 %37, %30
br i1 %38, label %39, label %31
39: ; preds = %31, %25
%40 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%41 = call i32* @popen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %39
%46 = call i32 @memset(i8* %8, i32 0, i32 2048)
%47 = call i32* @fgets(i8* %8, i32 2047, i32* %41)
%48 = icmp eq i32* %47, null
br i1 %48, label %53, label %49
49: ; preds = %45, %49
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%51 = call i32* @fgets(i8* %8, i32 2047, i32* %41)
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %49
53: ; preds = %49, %45
%54 = call i32 @pclose(i32* %41)
%55 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%57 = load i64, i64* %56
%58 = sitofp i64 %57 to double
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%60 = load i64, i64* %59
%61 = sitofp i64 %60 to double
%62 = call double @llvm.fmuladd.f64(double %58, double 1.000000e+06, double %61)
%63 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%64 = load i64, i64* %63
%65 = sitofp i64 %64 to double
%66 = fneg double %65
%67 = call double @llvm.fmuladd.f64(double %66, double 1.000000e+06, double %62)
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%69 = load i64, i64* %68
%70 = sitofp i64 %69 to double
%71 = fsub double %67, %70
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %71)
%73 = call i32 @WEXITSTATUS(i32 %54)
ret i32 %73
}