#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 max(int, int, int);
scalar_t__ min(int, int, int);
int /*<<< orphan*/ swap(int *, int *);
int main(void) {
  int x = 10;
  int y = 2;
  int z = 1;
  if (x <= y)
    swap(&x, &y);
  else if (x <= z)
    x += min(x, y, z);
  else
    z *= max(z, y, x);
  return (y <= z ? y + z : y - z);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1172 <main+0x42>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <swap@plt>
jmp    11b8 <main+0x88>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     119e <main+0x6e>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <min@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
jmp    11b3 <main+0x83>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1040 <max@plt>
imul   -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11b8 <main+0x88>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11d2 <main+0xa2>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11db <main+0xab>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0xa,%edx
call   1030 <max@plt>
mov    %eax,%ecx
neg    %ecx
cmp    $0x2,%eax
cmovl  %ecx,%eax
add    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 2, i32* %3
store i32 1, i32* %4
%5 = load i32, i32* %2
%6 = load i32, i32* %3
%7 = icmp sle i32 %5, %6
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @swap(i32* %2, i32* %3)
br label %31
10: ; preds = %0
%11 = load i32, i32* %2
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i64 @min(i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
br label %30
23: ; preds = %10
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = call i32 @max(i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* %4
%29 = mul nsw i32 %28, %27
store i32 %29, i32* %4
br label %30
30: ; preds = %23, %14
br label %31
31: ; preds = %30, %8
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = add nsw i32 %36, %37
br label %43
39: ; preds = %31
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = sub nsw i32 %40, %41
br label %43
43: ; preds = %39, %35
%44 = phi i32 [ %38, %35 ], [ %42, %39 ]
ret i32 %44
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @max(i32 1, i32 2, i32 10)
%2 = icmp slt i32 %1, 2
%3 = sub i32 0, %1
%4 = select i1 %2, i32 %3, i32 %1
%5 = add i32 %4, 2
ret i32 %5
}