#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int get_mosaic_dimension(FILE *file, int *width, int *height) {
  int c = fscanf(file, "%d\n%d\n", width, height);
  if (c != 2) {
    fputs("ERROR while reading width and height!\n", stderr);
    return EXIT_FAILURE;
  }
  if (*width <= 0 || *height <= 0) {
    fputs("ERROR: width and height must be greater than 0!\n", stderr);
    return EXIT_FAILURE;
  }
  if (*width >= 10000 || *height >= 10000) {
    fputs("ERROR: width and height must be less than 10000!\n", stderr);
    return EXIT_FAILURE;
  }
  assert(*width > 0 && *height >= 0);
  assert(*width < 10000 && *height < 10000);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<get_mosaic_dimension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xea9(%rip),%rsi
call   1040 <fscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
je     118f <get_mosaic_dimension+0x5f>
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <get_mosaic_dimension+0x14f>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11a9 <get_mosaic_dimension+0x79>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jg     11cf <get_mosaic_dimension+0x9f>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    0xe75(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <get_mosaic_dimension+0x14f>
mov    -0x18(%rbp),%rax
cmpl   $0x2710,(%rax)
jge    11ef <get_mosaic_dimension+0xbf>
mov    -0x20(%rbp),%rax
cmpl   $0x2710,(%rax)
jl     1215 <get_mosaic_dimension+0xe5>
mov    0x2dea(%rip),%rax
mov    (%rax),%esi
lea    0xe60(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127f <get_mosaic_dimension+0x14f>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,(%rcx)
mov    %al,-0x25(%rbp)
jle    1234 <get_mosaic_dimension+0x104>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
setge  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x2710,(%rcx)
mov    %al,-0x26(%rbp)
jge    1266 <get_mosaic_dimension+0x136>
mov    -0x20(%rbp),%rax
cmpl   $0x2710,(%rax)
setl   %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mosaic_dimension>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xebf(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    119c <get_mosaic_dimension+0x6c>
mov    (%rbx),%eax
test   %eax,%eax
jle    11ae <get_mosaic_dimension+0x7e>
mov    (%r14),%ecx
test   %ecx,%ecx
jle    11ae <get_mosaic_dimension+0x7e>
cmp    $0x270f,%eax
ja     11c0 <get_mosaic_dimension+0x90>
cmp    $0x2710,%ecx
jae    11c0 <get_mosaic_dimension+0x90>
mov    $0x1,%edi
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x270f,(%rbx)
jg     118e <get_mosaic_dimension+0x5e>
xor    %edi,%edi
cmpl   $0x2710,(%r14)
setl   %dil
call   1050 <assert@plt>
mov    0x2e36(%rip),%rax
jmp    11dc <get_mosaic_dimension+0xac>
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
lea    0xe5b(%rip),%rdi
jmp    11d0 <get_mosaic_dimension+0xa0>
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
jmp    11d0 <get_mosaic_dimension+0xa0>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d\0A%d\0A\00"
@.str.1 = [39 x i8] c"ERROR while reading width and height!\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [49 x i8] c"ERROR: width and height must be greater than 0!\0A\00"
@.str.3 = [50 x i8] c"ERROR: width and height must be less than 10000!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @get_mosaic_dimension(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i32*, i32** %5
%10 = load i32*, i32** %6
%11 = load i32*, i32** %7
%12 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* @stderr
%17 = call i32 @fputs(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %4
br label %67
19: ; preds = %3
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = icmp sle i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32*, i32** %7
%25 = load i32, i32* %24
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23, %19
%28 = load i32, i32* @stderr
%29 = call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %4
br label %67
31: ; preds = %23
%32 = load i32*, i32** %6
%33 = load i32, i32* %32
%34 = icmp sge i32 %33, 10000
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i32*, i32** %7
%37 = load i32, i32* %36
%38 = icmp sge i32 %37, 10000
br i1 %38, label %39, label %43
39: ; preds = %35, %31
%40 = load i32, i32* @stderr
%41 = call i32 @fputs(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @EXIT_FAILURE
store i32 %42, i32* %4
br label %67
43: ; preds = %35
%44 = load i32*, i32** %6
%45 = load i32, i32* %44
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32*, i32** %7
%49 = load i32, i32* %48
%50 = icmp sge i32 %49, 0
br label %51
51: ; preds = %47, %43
%52 = phi i1 [ false, %43 ], [ %50, %47 ]
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32*, i32** %6
%56 = load i32, i32* %55
%57 = icmp slt i32 %56, 10000
br i1 %57, label %58, label %62
58: ; preds = %51
%59 = load i32*, i32** %7
%60 = load i32, i32* %59
%61 = icmp slt i32 %60, 10000
br label %62
62: ; preds = %58, %51
%63 = phi i1 [ false, %51 ], [ %61, %58 ]
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i32, i32* @EXIT_SUCCESS
store i32 %66, i32* %4
br label %67
67: ; preds = %62, %39, %27, %15
%68 = load i32, i32* %4
ret i32 %68
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d\0A%d\0A\00"
@.str.1 = [39 x i8] c"ERROR while reading width and height!\0A\00"
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@.str.2 = [49 x i8] c"ERROR: width and height must be greater than 0!\0A\00"
@.str.3 = [50 x i8] c"ERROR: width and height must be less than 10000!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @get_mosaic_dimension(i32* nocapture %0, i32* %1, i32* %2) {
%4 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%5 = icmp eq i32 %4, 2
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fputs(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %36
9: ; preds = %3
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %18
15: ; preds = %12, %9
%16 = load i32, i32* @stderr
%17 = tail call i32 @fputs(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %36
18: ; preds = %12
%19 = icmp ugt i32 %10, 9999
%20 = icmp ugt i32 %13, 9999
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 @fputs(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %36
25: ; preds = %18
%26 = tail call i32 @assert(i32 1)
%27 = load i32, i32* %1
%28 = icmp slt i32 %27, 10000
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp slt i32 %30, 10000
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %29, %25
%34 = phi i32 [ 0, %25 ], [ %32, %29 ]
%35 = tail call i32 @assert(i32 %34)
br label %36
36: ; preds = %33, %22, %15, %6
%37 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %15 ], [ @EXIT_FAILURE, %22 ], [ @EXIT_SUCCESS, %33 ]
%38 = load i32, i32* %37
ret i32 %38
}