#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*/ printf(char *, ...);
scalar_t__ run_32(int);
scalar_t__ run_64(int);
int main() {
  int n, err = 0;
  for (n = 1; n <= 4; ++n) {
    err += run_32(n);
    err += run_64(n);
  };
  if (err)
    printf("failed with %d errors\n", err);
  else
    printf("passed\n");
  return err;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jg     118f <main+0x5f>
mov    -0x8(%rbp),%edi
call   1050 <run_32@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <run_64@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x1d>
cmpl   $0x0,-0xc(%rbp)
je     11af <main+0x7f>
mov    -0xc(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <main+0x8d>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1,%edi
call   1060 <run_32@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   1050 <run_64@plt>
mov    %rax,%r15
add    %r14d,%r15d
mov    $0x2,%edi
call   1060 <run_32@plt>
mov    %rax,%rbx
add    %r15d,%ebx
mov    $0x2,%edi
call   1050 <run_64@plt>
mov    %rax,%r14
add    %ebx,%r14d
mov    $0x3,%edi
call   1060 <run_32@plt>
mov    %rax,%rbx
add    %r14d,%ebx
mov    $0x3,%edi
call   1050 <run_64@plt>
mov    %rax,%r14
add    %ebx,%r14d
mov    $0x4,%edi
call   1060 <run_32@plt>
mov    %rax,%rbx
add    %r14d,%ebx
mov    $0x4,%edi
call   1050 <run_64@plt>
mov    %rax,%r14
add    %ebx,%r14d
je     11d7 <main+0x97>
lea    0xe35(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e3 <main+0xa3>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"failed with %d errors\0A\00"
@.str.1 = [8 x i8] c"passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %2
br label %4
4: ; preds = %20, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 4
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i64 @run_32(i32 %8)
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = add nsw i64 %11, %9
%13 = trunc i64 %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = call i64 @run_64(i32 %14)
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = add nsw i64 %17, %15
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
br label %20
20: ; preds = %7
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %4
23: ; preds = %4
%24 = load i32, i32* %3
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %31
29: ; preds = %23
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [23 x i8] c"failed with %d errors\0A\00"
@str = [7 x i8] c"passed\00"
define i32 @main() {
%1 = tail call i64 @run_32(i32 1)
%2 = trunc i64 %1 to i32
%3 = tail call i64 @run_64(i32 1)
%4 = trunc i64 %3 to i32
%5 = add i32 %2, %4
%6 = tail call i64 @run_32(i32 2)
%7 = trunc i64 %6 to i32
%8 = add i32 %5, %7
%9 = tail call i64 @run_64(i32 2)
%10 = trunc i64 %9 to i32
%11 = add i32 %8, %10
%12 = tail call i64 @run_32(i32 3)
%13 = trunc i64 %12 to i32
%14 = add i32 %11, %13
%15 = tail call i64 @run_64(i32 3)
%16 = trunc i64 %15 to i32
%17 = add i32 %14, %16
%18 = tail call i64 @run_32(i32 4)
%19 = trunc i64 %18 to i32
%20 = add i32 %17, %19
%21 = tail call i64 @run_64(i32 4)
%22 = trunc i64 %21 to i32
%23 = add i32 %20, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %0
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %23)
br label %29
27: ; preds = %0
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
ret i32 %23
}