#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 cut_one(int, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x = -1, y = -1, w = -1, h = -1;
  do {
    printf("X: ");
    scanf("%d", &x);
  } while (x <= 0);
  do {
    printf("Y: ");
    scanf("%d", &y);
  } while (y <= 0);
  do {
    printf("W: ");
    scanf("%d", &w);
  } while (w <= 0);
  do {
    printf("H: ");
    scanf("%d", &h);
  } while (h <= 0);
  if (cut_one(x, y, w, h, 0) > cut_one(y, x, w, h, 0)) {
    cut_one(x, y, w, h, 1);
    printf("\nNumber of tiles: %d\n", cut_one(x, y, w, h, 0));
  } else {
    cut_one(y, x, w, h, 1);
    printf("\nNumber of tiles: %d\n", cut_one(y, x, w, h, 0));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    115b <main+0x2b>
jmp    1188 <main+0x58>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1188 <main+0x58>
jmp    11b5 <main+0x85>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    11b5 <main+0x85>
jmp    11e2 <main+0xb2>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11e2 <main+0xb2>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jle    1282 <main+0x152>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%r8d
call   1040 <cut_one@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
mov    %eax,%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bd <main+0x18d>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%r8d
call   1040 <cut_one@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
mov    %eax,%esi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0xffffffff,0x8(%rsp)
ff
movl   $0xffffffff,0x4(%rsp)
ff
movl   $0xffffffff,(%rsp)
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xea1(%rip),%r14
lea    0xe9e(%rip),%r15
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1170 <main+0x40>
lea    0xe74(%rip),%r14
lea    0xe6a(%rip),%r15
lea    0x4(%rsp),%rbx
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11a0 <main+0x70>
lea    0xe48(%rip),%r14
lea    0xe3a(%rip),%r15
mov    %rsp,%rbx
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x0,(%rsp)
jle    11d0 <main+0xa0>
lea    0xe1d(%rip),%r14
lea    0xe0b(%rip),%r15
lea    0xc(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    1200 <main+0xd0>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
mov    %eax,%ebx
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
mov    (%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
cmp    %eax,%ebx
jle    1271 <main+0x141>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    0xc(%rsp),%ecx
mov    $0x1,%r8d
call   1040 <cut_one@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
jmp    1293 <main+0x163>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
mov    (%rsp),%edx
mov    0xc(%rsp),%ecx
mov    $0x1,%r8d
call   1040 <cut_one@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
mov    (%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %r8d,%r8d
call   1040 <cut_one@plt>
lea    0xd6a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"Y: \00"
@.str.3 = [4 x i8] c"W: \00"
@.str.4 = [4 x i8] c"H: \00"
@.str.5 = [22 x i8] c"\0ANumber of tiles: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
store i32 -1, i32* %3
store i32 -1, i32* %4
store i32 -1, i32* %5
br label %6
6: ; preds = %9, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %9
br label %13
13: ; preds = %16, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
br label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp sle i32 %17, 0
br i1 %18, label %13, label %19
19: ; preds = %16
br label %20
20: ; preds = %23, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp sle i32 %24, 0
br i1 %25, label %20, label %26
26: ; preds = %23
br label %27
27: ; preds = %30, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
br label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = icmp sle i32 %31, 0
br i1 %32, label %27, label %33
33: ; preds = %30
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = call i32 @cut_one(i32 %34, i32 %35, i32 %36, i32 %37, i32 0)
%39 = load i32, i32* %3
%40 = load i32, i32* %2
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = call i32 @cut_one(i32 %39, i32 %40, i32 %41, i32 %42, i32 0)
%44 = icmp sgt i32 %38, %43
br i1 %44, label %45, label %57
45: ; preds = %33
%46 = load i32, i32* %2
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = call i32 @cut_one(i32 %46, i32 %47, i32 %48, i32 %49, i32 1)
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = load i32, i32* %5
%55 = call i32 @cut_one(i32 %51, i32 %52, i32 %53, i32 %54, i32 0)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %55)
br label %69
57: ; preds = %33
%58 = load i32, i32* %3
%59 = load i32, i32* %2
%60 = load i32, i32* %4
%61 = load i32, i32* %5
%62 = call i32 @cut_one(i32 %58, i32 %59, i32 %60, i32 %61, i32 1)
%63 = load i32, i32* %3
%64 = load i32, i32* %2
%65 = load i32, i32* %4
%66 = load i32, i32* %5
%67 = call i32 @cut_one(i32 %63, i32 %64, i32 %65, i32 %66, i32 0)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %57, %45
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"X: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"Y: \00"
@.str.3 = [4 x i8] c"W: \00"
@.str.4 = [4 x i8] c"H: \00"
@.str.5 = [22 x i8] c"\0ANumber of tiles: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 -1, i32* %2
%7 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
br label %9
9: ; preds = %9, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp slt i32 %12, 1
br i1 %13, label %9, label %14
14: ; preds = %9, %14
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 1
br i1 %18, label %14, label %19
19: ; preds = %14, %19
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %3
%23 = icmp slt i32 %22, 1
br i1 %23, label %19, label %24
24: ; preds = %19, %24
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 1
br i1 %28, label %24, label %29
29: ; preds = %24
%30 = load i32, i32* %1
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @cut_one(i32 %30, i32 %31, i32 %32, i32 %27, i32 0)
%34 = load i32, i32* %2
%35 = load i32, i32* %1
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 @cut_one(i32 %34, i32 %35, i32 %36, i32 %37, i32 0)
%39 = icmp sgt i32 %33, %38
br i1 %39, label %40, label %51
40: ; preds = %29
%41 = load i32, i32* %1
%42 = load i32, i32* %2
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = call i32 @cut_one(i32 %41, i32 %42, i32 %43, i32 %44, i32 1)
%46 = load i32, i32* %1
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = call i32 @cut_one(i32 %46, i32 %47, i32 %48, i32 %49, i32 0)
br label %62
51: ; preds = %29
%52 = load i32, i32* %2
%53 = load i32, i32* %1
%54 = load i32, i32* %3
%55 = load i32, i32* %4
%56 = call i32 @cut_one(i32 %52, i32 %53, i32 %54, i32 %55, i32 1)
%57 = load i32, i32* %2
%58 = load i32, i32* %1
%59 = load i32, i32* %3
%60 = load i32, i32* %4
%61 = call i32 @cut_one(i32 %57, i32 %58, i32 %59, i32 %60, i32 0)
br label %62
62: ; preds = %51, %40
%63 = phi i32 [ %61, %51 ], [ %50, %40 ]
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %63)
ret i32 0
}