#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double in_sec(struct timeval *, struct timeval *);
int /*<<< orphan*/ stderr;
int system(char *);
double launch(char *cmd) {
  struct timeval start, end;
  int ret;
  gettimeofday(&start, NULL);
  ret = system(cmd);
  if (ret != 0)
    fprintf(stderr, "ERROR: %s failed with error code %d\n", cmd, ret);
  gettimeofday(&end, NULL);
  return in_sec(&start, &end);
}


x86 assembly (clang, -O0):
<launch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118b <launch+0x4b>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe7a(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <in_sec@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launch>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
test   %eax,%eax
je     1178 <launch+0x38>
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%edi
lea    0xe92(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1060 <fprintf@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1050 <in_sec@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: %s failed with error code %d\0A\00"
define double @launch(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%7 = load i8*, i8** %2
%8 = call i32 @system(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = load i32, i32* %5
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %14)
br label %16
16: ; preds = %11, %1
%17 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%18 = call double @in_sec(%struct.timeval* %3, %struct.timeval* %4)
ret double %18
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [37 x i8] c"ERROR: %s failed with error code %d\0A\00"
define double @launch(i8* %0) {
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %2 to i8*
%5 = bitcast %struct.timeval* %3 to i8*
%6 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%7 = tail call i32 @system(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %7)
br label %12
12: ; preds = %9, %1
%13 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%14 = call double @in_sec(%struct.timeval* %2, %struct.timeval* %3)
ret double %14
}