#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 abs(int);
int /*<<< orphan*/ printf(char *, ...);
int check_fields(int begin_x, int begin_y, int x, int y, int length) {
  int i = 0;
  if (begin_x != x && begin_y == y)
    i = abs(begin_x - x) + 1;
  else if (begin_x == x && begin_y != y) {
    i = abs(begin_y - y) + 1;
  } else {
    printf("Podaj inne pole tak, by statek nie zginal sie.\n");
    return 0;
  }
  if (i == 0) {
    printf("Podaj pole inne niz poczatek.\n");
    return 0;
  } else if (i != length) {
    printf("Podaj inne pole tak by statek mial dlugosc %d.\n", length);
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<check_fields>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     116d <check_fields+0x4d>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    116d <check_fields+0x4d>
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1030 <abs@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ba <check_fields+0x9a>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    119b <check_fields+0x7b>
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     119b <check_fields+0x7b>
mov    -0xc(%rbp),%edi
sub    -0x14(%rbp),%edi
call   1030 <abs@plt>
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b5 <check_fields+0x95>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <check_fields+0xee>
jmp    11ba <check_fields+0x9a>
cmpl   $0x0,-0x1c(%rbp)
jne    11de <check_fields+0xbe>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <check_fields+0xee>
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     1207 <check_fields+0xe7>
mov    -0x18(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120e <check_fields+0xee>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_fields>:
push   %rbx
mov    %edi,%eax
sub    %edx,%eax
je     112b <check_fields+0xb>
cmp    %ecx,%esi
je     1135 <check_fields+0x15>
cmp    %edx,%edi
jne    115e <check_fields+0x3e>
sub    %ecx,%esi
je     115e <check_fields+0x3e>
mov    %esi,%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
add    $0x1,%ecx
mov    $0x1,%ebx
cmp    %r8d,%ecx
je     116c <check_fields+0x4c>
lea    0xeb0(%rip),%rdi
xor    %ebx,%ebx
mov    %r8d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116c <check_fields+0x4c>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Podaj inne pole tak, by statek nie zginal sie.\0A\00"
@.str.1 = [31 x i8] c"Podaj pole inne niz poczatek.\0A\00"
@.str.2 = [48 x i8] c"Podaj inne pole tak by statek mial dlugosc %d.\0A\00"
define i32 @check_fields(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %12
%13 = load i32, i32* %7
%14 = load i32, i32* %9
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %5
%17 = load i32, i32* %8
%18 = load i32, i32* %10
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %9
%23 = sub nsw i32 %21, %22
%24 = call i32 @abs(i32 %23)
%25 = add nsw i32 %24, 1
store i32 %25, i32* %12
br label %43
26: ; preds = %16, %5
%27 = load i32, i32* %7
%28 = load i32, i32* %9
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32, i32* %8
%32 = load i32, i32* %10
%33 = icmp ne i32 %31, %32
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %8
%36 = load i32, i32* %10
%37 = sub nsw i32 %35, %36
%38 = call i32 @abs(i32 %37)
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %42
40: ; preds = %30, %26
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %56
42: ; preds = %34
br label %43
43: ; preds = %42, %20
%44 = load i32, i32* %12
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %56
48: ; preds = %43
%49 = load i32, i32* %12
%50 = load i32, i32* %11
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* %11
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %53)
store i32 0, i32* %6
br label %56
55: ; preds = %48
store i32 1, i32* %6
br label %56
56: ; preds = %55, %52, %46, %40
%57 = load i32, i32* %6
ret i32 %57
}

LLVM IR (-O2):
@.str.2 = [48 x i8] c"Podaj inne pole tak by statek mial dlugosc %d.\0A\00"
@str = [47 x i8] c"Podaj inne pole tak, by statek nie zginal sie.\00"
define i32 @check_fields(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ne i32 %0, %2
%7 = icmp eq i32 %1, %3
%8 = and i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = sub nsw i32 %0, %2
br label %17
11: ; preds = %5
%12 = or i1 %6, %7
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = sub nsw i32 %1, %3
br label %17
15: ; preds = %11
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %24
17: ; preds = %9, %13
%18 = phi i32 [ %10, %9 ], [ %14, %13 ]
%19 = tail call i32 @llvm.abs.i32(i32 %18, i1 true)
%20 = add nuw nsw i32 %19, 1
%21 = icmp eq i32 %20, %4
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %24
24: ; preds = %17, %22, %15
%25 = phi i32 [ 0, %22 ], [ 0, %15 ], [ 1, %17 ]
ret i32 %25
}