#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_FAILURE;
int /*<<< orphan*/ assert(int);
int count_variables(char const *const *);
int /*<<< orphan*/ kyua_error_err(int /*<<< orphan*/, int /*<<< orphan*/,
                                  char *);
int /*<<< orphan*/ kyua_oom_error_new();
int /*<<< orphan*/ kyua_run_exec(char const *, char const **);
char **malloc(int);
void exec_body(const char *test_program, const char *test_case,
               const char *result_file, const char *const user_variables[]) {
  const size_t nargs = 1 + 2 + 2 * count_variables(user_variables) + 1 + 1;
  const char **args = malloc(sizeof(const char *) * nargs);
  if (args == NULL)
    kyua_error_err(EXIT_FAILURE, kyua_oom_error_new(),
                   "Failed to construct arguments list");
  size_t i = 0;
  args[i++] = test_program;
  args[i++] = "-r";
  args[i++] = result_file;
  const char *const *iter;
  for (iter = user_variables; *iter != NULL; ++iter) {
    args[i++] = "-v";
    args[i++] = *iter;
  }
  args[i++] = test_case;
  args[i++] = NULL;
  assert(i == nargs);
  kyua_run_exec(test_program, args);
}


x86 assembly (clang, -O0):
<exec_body>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <count_variables@plt>
shl    $0x1,%eax
add    $0x3,%eax
add    $0x1,%eax
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11d5 <exec_body+0x75>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   1030 <kyua_oom_error_new@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
lea    0xe30(%rip),%rdx
call   1070 <kyua_error_err@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
lea    0xe11(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmpq   $0x0,(%rax)
je     1294 <exec_body+0x134>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
lea    0xdc5(%rip),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    (%rax),%rdx
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
jmp    1239 <exec_body+0xd9>
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
movq   $0x0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <kyua_run_exec@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_body>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rcx,%rdi
call   1060 <count_variables@plt>
mov    %eax,%ebp
add    %eax,%eax
lea    0x28(,%rax,8),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c1 <exec_body+0x61>
mov    0x2e42(%rip),%rax
mov    %r14,(%rsp)
mov    (%rax),%r14d
xor    %eax,%eax
call   1030 <kyua_oom_error_new@plt>
lea    0xe4d(%rip),%rdx
mov    %r14d,%edi
mov    (%rsp),%r14
mov    %eax,%esi
call   1070 <kyua_error_err@plt>
lea    0x5(%rbp,%rbp,1),%eax
mov    %r15,(%rbx)
lea    0xe54(%rip),%rcx
mov    %rcx,0x8(%rbx)
mov    %r13,0x10(%rbx)
mov    (%r12),%rdx
test   %rdx,%rdx
je     120e <exec_body+0xae>
xor    %ecx,%ecx
lea    0xe3d(%rip),%rsi
nopl   0x0(%rax)
mov    %rsi,0x18(%rbx,%rcx,8)
mov    %rdx,0x20(%rbx,%rcx,8)
mov    0x8(%r12,%rcx,4),%rdx
add    $0x2,%rcx
test   %rdx,%rdx
jne    11f0 <exec_body+0x90>
add    $0x3,%rcx
jmp    1213 <exec_body+0xb3>
mov    $0x3,%ecx
cltq
mov    %r14,(%rbx,%rcx,8)
movq   $0x0,0x8(%rbx,%rcx,8)
add    $0x2,%rcx
xor    %edi,%edi
cmp    %rax,%rcx
sete   %dil
call   1050 <assert@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <kyua_run_exec@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [35 x i8] c"Failed to construct arguments list\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-v\00"
define void @exec_body(i8* %0, i8* %1, i8* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i64
%10 = alloca i8**
%11 = alloca i64
%12 = alloca i8**
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8** %3, i8*** %8
%13 = load i8**, i8*** %8
%14 = call i32 @count_variables(i8** %13)
%15 = mul nsw i32 2, %14
%16 = add nsw i32 3, %15
%17 = add nsw i32 %16, 1
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
store i64 %19, i64* %9
%20 = load i64, i64* %9
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i8** @malloc(i32 %22)
store i8** %23, i8*** %10
%24 = load i8**, i8*** %10
%25 = icmp eq i8** %24, null
br i1 %25, label %26, label %30
26: ; preds = %4
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 (...) @kyua_oom_error_new()
%29 = call i32 @kyua_error_err(i32 %27, i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %26, %4
store i64 0, i64* %11
%31 = load i8*, i8** %5
%32 = load i8**, i8*** %10
%33 = load i64, i64* %11
%34 = add i64 %33, 1
store i64 %34, i64* %11
%35 = getelementptr inbounds i8*, i8** %32, i64 %33
store i8* %31, i8** %35
%36 = load i8**, i8*** %10
%37 = load i64, i64* %11
%38 = add i64 %37, 1
store i64 %38, i64* %11
%39 = getelementptr inbounds i8*, i8** %36, i64 %37
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %39
%40 = load i8*, i8** %7
%41 = load i8**, i8*** %10
%42 = load i64, i64* %11
%43 = add i64 %42, 1
store i64 %43, i64* %11
%44 = getelementptr inbounds i8*, i8** %41, i64 %42
store i8* %40, i8** %44
%45 = load i8**, i8*** %8
store i8** %45, i8*** %12
br label %46
46: ; preds = %61, %30
%47 = load i8**, i8*** %12
%48 = load i8*, i8** %47
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %64
50: ; preds = %46
%51 = load i8**, i8*** %10
%52 = load i64, i64* %11
%53 = add i64 %52, 1
store i64 %53, i64* %11
%54 = getelementptr inbounds i8*, i8** %51, i64 %52
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %54
%55 = load i8**, i8*** %12
%56 = load i8*, i8** %55
%57 = load i8**, i8*** %10
%58 = load i64, i64* %11
%59 = add i64 %58, 1
store i64 %59, i64* %11
%60 = getelementptr inbounds i8*, i8** %57, i64 %58
store i8* %56, i8** %60
br label %61
61: ; preds = %50
%62 = load i8**, i8*** %12
%63 = getelementptr inbounds i8*, i8** %62, i32 1
store i8** %63, i8*** %12
br label %46
64: ; preds = %46
%65 = load i8*, i8** %6
%66 = load i8**, i8*** %10
%67 = load i64, i64* %11
%68 = add i64 %67, 1
store i64 %68, i64* %11
%69 = getelementptr inbounds i8*, i8** %66, i64 %67
store i8* %65, i8** %69
%70 = load i8**, i8*** %10
%71 = load i64, i64* %11
%72 = add i64 %71, 1
store i64 %72, i64* %11
%73 = getelementptr inbounds i8*, i8** %70, i64 %71
store i8* null, i8** %73
%74 = load i64, i64* %11
%75 = load i64, i64* %9
%76 = icmp eq i64 %74, %75
%77 = zext i1 %76 to i32
%78 = call i32 @assert(i32 %77)
%79 = load i8*, i8** %5
%80 = load i8**, i8*** %10
%81 = call i32 @kyua_run_exec(i8* %79, i8** %80)
ret void
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [35 x i8] c"Failed to construct arguments list\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-v\00"
define void @exec_body(i8* %0, i8* %1, i8* %2, i8** %3) {
%5 = tail call i32 @count_variables(i8** %3)
%6 = shl nsw i32 %5, 1
%7 = add nsw i32 %6, 5
%8 = shl i32 %7, 3
%9 = tail call i8** @malloc(i32 %8)
%10 = icmp eq i8** %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 (...) @kyua_oom_error_new()
%14 = tail call i32 @kyua_error_err(i32 %12, i32 %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %11, %4
store i8* %0, i8** %9
%16 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds i8*, i8** %9, i64 2
store i8* %2, i8** %17
%18 = load i8*, i8** %3
%19 = icmp eq i8* %18, null
br i1 %19, label %31, label %20
20: ; preds = %15, %20
%21 = phi i8* [ %29, %20 ], [ %18, %15 ]
%22 = phi i8** [ %28, %20 ], [ %3, %15 ]
%23 = phi i64 [ %26, %20 ], [ 3, %15 ]
%24 = add i64 %23, 1
%25 = getelementptr inbounds i8*, i8** %9, i64 %23
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %25
%26 = add i64 %23, 2
%27 = getelementptr inbounds i8*, i8** %9, i64 %24
store i8* %21, i8** %27
%28 = getelementptr inbounds i8*, i8** %22, i64 1
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %20
31: ; preds = %20, %15
%32 = phi i64 [ 3, %15 ], [ %26, %20 ]
%33 = sext i32 %7 to i64
%34 = add i64 %32, 1
%35 = getelementptr inbounds i8*, i8** %9, i64 %32
store i8* %1, i8** %35
%36 = add i64 %32, 2
%37 = getelementptr inbounds i8*, i8** %9, i64 %34
store i8* null, i8** %37
%38 = icmp eq i64 %36, %33
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
%41 = tail call i32 @kyua_run_exec(i8* %0, i8** %9)
ret void
}