#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, unsigned int *, unsigned int *,
                  unsigned int *, unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp;
  unsigned a, b, x, y;
  if (argc != 2) {
    printf("Usage: %s [FILE]\n", argv[0]);
    return 1;
  }
  fp = fopen(*++argv, "r");
  while (fscanf(fp, "%dx%d | %d %d", &a, &b, &x, &y) != EOF) {
    unsigned r = 0, t;
    while (b > y) {
      r += a;
      t = a;
      a = b - 1;
      b = t;
      t = x;
      x = a + 1 - y;
      y = t;
    }
    printf("%d\n", r + x);
  }
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <main+0x102>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
lea    0xe87(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1040 <fscanf@plt>
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%rax
je     122b <main+0xfb>
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jbe    1212 <main+0xe2>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
sub    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11cb <main+0x9b>
mov    -0x2c(%rbp),%esi
add    -0x24(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <main+0x64>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    122d <main+0xfd>
mov    0x8(%rsi),%rdi
lea    0xec0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
lea    0xeb3(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    0x2e64(%rip),%rbx
xor    %r13d,%r13d
cmp    (%rbx),%rax
je     1244 <main+0x114>
lea    0xe8b(%rip),%rbp
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
xor    %r13d,%r13d
jmp    11e2 <main+0xb2>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
add    %eax,%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
lea    0xe4c(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r14,%r8
mov    %r15,%r9
call   1040 <fscanf@plt>
cmp    (%rbx),%rax
je     1244 <main+0x114>
mov    0x10(%rsp),%ecx
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
cmp    %edx,%ecx
jbe    11b0 <main+0x80>
mov    %rbp,%r9
mov    %rbx,%r8
xor    %eax,%eax
mov    0x14(%rsp),%ebp
xchg   %ax,%ax
mov    %esi,%edi
mov    %ebp,%ebx
add    %ebp,%eax
lea    -0x1(%rcx),%ebp
mov    %ecx,%esi
sub    %edx,%esi
mov    %ebx,%ecx
mov    %edi,%edx
cmp    %edi,%ebx
ja     1200 <main+0xd0>
mov    %ebp,0x14(%rsp)
mov    %ebx,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %edi,0x8(%rsp)
mov    %r8,%rbx
mov    %r9,%rbp
jmp    11b2 <main+0x82>
mov    (%rsi),%rsi
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r13d
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%dx%d | %d %d\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%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
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %55
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i32 1
store i8** %22, i8*** %5
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
br label %25
25: ; preds = %49, %20
%26 = load i32*, i32** %6
%27 = call i64 @fscanf(i32* %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10)
%28 = load i64, i64* @EOF
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %54
30: ; preds = %25
store i32 0, i32* %11
br label %31
31: ; preds = %35, %30
%32 = load i32, i32* %8
%33 = load i32, i32* %10
%34 = icmp ugt i32 %32, %33
br i1 %34, label %35, label %49
35: ; preds = %31
%36 = load i32, i32* %7
%37 = load i32, i32* %11
%38 = add i32 %37, %36
store i32 %38, i32* %11
%39 = load i32, i32* %7
store i32 %39, i32* %12
%40 = load i32, i32* %8
%41 = sub i32 %40, 1
store i32 %41, i32* %7
%42 = load i32, i32* %12
store i32 %42, i32* %8
%43 = load i32, i32* %9
store i32 %43, i32* %12
%44 = load i32, i32* %7
%45 = add i32 %44, 1
%46 = load i32, i32* %10
%47 = sub i32 %45, %46
store i32 %47, i32* %9
%48 = load i32, i32* %12
store i32 %48, i32* %10
br label %31
49: ; preds = %31
%50 = load i32, i32* %11
%51 = load i32, i32* %9
%52 = add i32 %50, %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
br label %25
54: ; preds = %25
store i32 0, i32* %3
br label %55
55: ; preds = %54, %15
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [18 x i8] c"Usage: %s [FILE]\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"%dx%d | %d %d\00"
@EOF = global i64 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %48
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i64 @fscanf(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %48, label %22
22: ; preds = %15, %40
%23 = load i32, i32* %4
%24 = load i32, i32* %6
%25 = load i32, i32* %5
%26 = icmp ugt i32 %23, %24
br i1 %26, label %27, label %40
27: ; preds = %22
%28 = load i32, i32* %3
br label %29
29: ; preds = %27, %29
%30 = phi i32 [ %35, %29 ], [ 0, %27 ]
%31 = phi i32 [ %33, %29 ], [ %23, %27 ]
%32 = phi i32 [ %34, %29 ], [ %24, %27 ]
%33 = phi i32 [ %36, %29 ], [ %28, %27 ]
%34 = phi i32 [ %37, %29 ], [ %25, %27 ]
%35 = add i32 %33, %30
%36 = add i32 %31, -1
%37 = sub i32 %31, %32
%38 = icmp ugt i32 %33, %34
br i1 %38, label %29, label %39
39: ; preds = %29
store i32 %36, i32* %3
store i32 %33, i32* %4
store i32 %37, i32* %5
store i32 %34, i32* %6
br label %40
40: ; preds = %39, %22
%41 = phi i32 [ %37, %39 ], [ %25, %22 ]
%42 = phi i32 [ %35, %39 ], [ 0, %22 ]
%43 = add i32 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = call i64 @fscanf(i32* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%46 = load i64, i64* @EOF
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %22
48: ; preds = %40, %15, %12
%49 = phi i32 [ 1, %12 ], [ 0, %15 ], [ 0, %40 ]
ret i32 %49
}