#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 median3(int, int, int);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(int c, char **v) {
  int i, j, k;
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++)
      for (k = 0; k < 3; k++)
        printf("m3 %d,%d,%d = %d\n", i, j, k, median3(i, j, k));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11d5 <main+0xb5>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11c2 <main+0xa2>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11af <main+0x8f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <median3@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    %eax,%r8d
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115f <main+0x3f>
jmp    11b4 <main+0x94>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <main+0x2e>
jmp    11c7 <main+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0xed3(%rip),%r14
nopl   (%rax)
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
mov    $0x2,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
xor    %edx,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
mov    $0x1,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    %ebx,%edi
mov    $0x2,%esi
mov    $0x2,%edx
call   1040 <median3@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x3,%ebx
jne    1130 <main+0x10>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"m3 %d,%d,%d = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %9
9: ; preds = %37, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %40
12: ; preds = %9
store i32 0, i32* %7
br label %13
13: ; preds = %33, %12
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %36
16: ; preds = %13
store i32 0, i32* %8
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = call i32 @median3(i32 %24, i32 %25, i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23, i32 %27)
br label %29
29: ; preds = %20
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %17
32: ; preds = %17
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %13
36: ; preds = %13
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %9
40: ; preds = %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [18 x i8] c"m3 %d,%d,%d = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %23, %3 ]
%5 = tail call i32 @median3(i32 %4, i32 0, i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0, i32 0, i32 %5)
%7 = tail call i32 @median3(i32 %4, i32 0, i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0, i32 1, i32 %7)
%9 = tail call i32 @median3(i32 %4, i32 0, i32 2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 0, i32 2, i32 %9)
%11 = tail call i32 @median3(i32 %4, i32 1, i32 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 1, i32 0, i32 %11)
%13 = tail call i32 @median3(i32 %4, i32 1, i32 1)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 1, i32 1, i32 %13)
%15 = tail call i32 @median3(i32 %4, i32 1, i32 2)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 1, i32 2, i32 %15)
%17 = tail call i32 @median3(i32 %4, i32 2, i32 0)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 2, i32 0, i32 %17)
%19 = tail call i32 @median3(i32 %4, i32 2, i32 1)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 2, i32 1, i32 %19)
%21 = tail call i32 @median3(i32 %4, i32 2, i32 2)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 2, i32 2, i32 %21)
%23 = add nuw nsw i32 %4, 1
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %3
25: ; preds = %3
ret i32 0
}