#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, unsigned int *, unsigned int *, unsigned int *,
           unsigned int *);
int /*<<< orphan*/ stdin;
main() {
  union {
    long long q;
    unsigned int v[2];
  } a, b, q, r;
  char buf[300];
  extern long long __qdivrem(unsigned long long, unsigned long long,
                             unsigned long long *);
  for (;;) {
    printf("> ");
    if (fgets(buf, sizeof buf, stdin) == NULL)
      break;
    if (sscanf(buf, "%u:%u %u:%u", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 &&
        sscanf(buf, "0x%x:%x 0x%x:%x", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) !=
            4) {
      printf("eh?\n");
      continue;
    }
    q.q = __qdivrem(a.q, b.q, &r.q);
    printf("%x:%x /%% %x:%x => q=%x:%x r=%x:%x\n", a.v[0], a.v[1], b.v[0],
           b.v[1], q.v[0], q.v[1], r.v[0], r.v[1]);
    printf("  = %X%08X / %X%08X => %X%08X\n  = %X%08X %% %X%08X => %X%08X\n",
           a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1], a.v[0], a.v[1],
           b.v[0], b.v[1], r.v[0], r.v[1]);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a0,%rsp
movl   $0x0,-0x24(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x180(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
mov    $0x12c,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    11a0 <main+0x50>
jmp    12c5 <main+0x175>
lea    -0x180(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x30(%rbp),%rcx
add    $0x4,%rcx
lea    -0x38(%rbp),%r8
lea    -0x38(%rbp),%r9
add    $0x4,%r9
lea    0xe3d(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     121b <main+0xcb>
lea    -0x180(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x30(%rbp),%rcx
add    $0x4,%rcx
lea    -0x38(%rbp),%r8
lea    -0x38(%rbp),%r9
add    $0x4,%r9
lea    0xe15(%rip),%rsi
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     121b <main+0xcb>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1169 <main+0x19>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1040 <__qdivrem@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x40(%rbp),%r9d
mov    -0x3c(%rbp),%r11d
mov    -0x48(%rbp),%r10d
mov    -0x44(%rbp),%eax
lea    0xdd1(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    -0x40(%rbp),%r9d
mov    -0x3c(%rbp),%r12d
mov    -0x30(%rbp),%r15d
mov    -0x2c(%rbp),%r14d
mov    -0x38(%rbp),%ebx
mov    -0x34(%rbp),%r11d
mov    -0x48(%rbp),%r10d
mov    -0x44(%rbp),%eax
lea    0xdaf(%rip),%rdi
mov    %r12d,(%rsp)
mov    %r15d,0x8(%rsp)
mov    %r14d,0x10(%rsp)
mov    %ebx,0x18(%rsp)
mov    %r11d,0x20(%rsp)
mov    %r10d,0x28(%rsp)
mov    %eax,0x30(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1169 <main+0x19>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x12c,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    11a3 <main+0x43>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0x14(%rsp),%r12
lea    0xc(%rsp),%rbp
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r13
jmp    129b <main+0x13b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1050 <__qdivrem@plt>
mov    %rax,%r15
mov    %rax,%r14
shr    $0x20,%r14
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x18(%rsp),%ebp
mov    0x1c(%rsp),%ebx
sub    $0x8,%rsp
lea    0xe0d(%rip),%rdi
mov    %r15d,%r9d
xor    %eax,%eax
push   %rbx
push   %rbp
push   %r14
call   1040 <printf@plt>
add    $0x20,%rsp
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x18(%rsp),%ebp
mov    0x1c(%rsp),%ebx
sub    $0x8,%rsp
lea    0xdfb(%rip),%rdi
mov    %r15d,%r9d
xor    %eax,%eax
push   %rbx
push   %rbp
push   %r8
push   %rcx
push   %rdx
push   %rsi
push   %r14
lea    0x50(%rsp),%r14
lea    0x60(%rsp),%rbx
lea    0x4c(%rsp),%rbp
call   1040 <printf@plt>
add    $0x40,%rsp
lea    0xd8b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x12c,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     119c <main+0x3c>
mov    %rbx,%rdi
lea    0xd5e(%rip),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1070 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
mov    %rbx,%rdi
lea    0xd46(%rip),%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
call   1070 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
lea    0xd97(%rip),%rdi
call   1030 <puts@plt>
jmp    126e <main+0x10e>

LLVM IR (-O0):
%union.anon = type { i64 }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [12 x i8] c"%u:%u %u:%u\00"
@.str.2 = [16 x i8] c"0x%x:%x 0x%x:%x\00"
@.str.3 = [5 x i8] c"eh?\0A\00"
@.str.4 = [36 x i8] c"%x:%x /%% %x:%x => q=%x:%x r=%x:%x\0A\00"
@.str.5 = [62 x i8] c" = %X%08X / %X%08X => %X%08X\0A = %X%08X %% %X%08X => %X%08X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %union.anon
%3 = alloca %union.anon
%4 = alloca %union.anon
%5 = alloca %union.anon
%6 = alloca [300 x i8]
store i32 0, i32* %1
br label %7
7: ; preds = %40, %38, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %9, i32 300, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %7
br label %110
14: ; preds = %7
%15 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%16 = bitcast %union.anon* %2 to [2 x i32]*
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%18 = bitcast %union.anon* %2 to [2 x i32]*
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %18, i64 0, i64 1
%20 = bitcast %union.anon* %3 to [2 x i32]*
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %20, i64 0, i64 0
%22 = bitcast %union.anon* %3 to [2 x i32]*
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %22, i64 0, i64 1
%24 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %17, i32* %19, i32* %21, i32* %23)
%25 = icmp ne i32 %24, 4
br i1 %25, label %26, label %40
26: ; preds = %14
%27 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%28 = bitcast %union.anon* %2 to [2 x i32]*
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %28, i64 0, i64 0
%30 = bitcast %union.anon* %2 to [2 x i32]*
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %30, i64 0, i64 1
%32 = bitcast %union.anon* %3 to [2 x i32]*
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %32, i64 0, i64 0
%34 = bitcast %union.anon* %3 to [2 x i32]*
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %34, i64 0, i64 1
%36 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %29, i32* %31, i32* %33, i32* %35)
%37 = icmp ne i32 %36, 4
br i1 %37, label %38, label %40
38: ; preds = %26
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %7
40: ; preds = %26, %14
%41 = bitcast %union.anon* %2 to i64*
%42 = load i64, i64* %41
%43 = bitcast %union.anon* %3 to i64*
%44 = load i64, i64* %43
%45 = bitcast %union.anon* %5 to i64*
%46 = call i64 @__qdivrem(i64 %42, i64 %44, i64* %45)
%47 = bitcast %union.anon* %4 to i64*
store i64 %46, i64* %47
%48 = bitcast %union.anon* %2 to [2 x i32]*
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %48, i64 0, i64 0
%50 = load i32, i32* %49
%51 = bitcast %union.anon* %2 to [2 x i32]*
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %51, i64 0, i64 1
%53 = load i32, i32* %52
%54 = bitcast %union.anon* %3 to [2 x i32]*
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %54, i64 0, i64 0
%56 = load i32, i32* %55
%57 = bitcast %union.anon* %3 to [2 x i32]*
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %57, i64 0, i64 1
%59 = load i32, i32* %58
%60 = bitcast %union.anon* %4 to [2 x i32]*
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %60, i64 0, i64 0
%62 = load i32, i32* %61
%63 = bitcast %union.anon* %4 to [2 x i32]*
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %63, i64 0, i64 1
%65 = load i32, i32* %64
%66 = bitcast %union.anon* %5 to [2 x i32]*
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %66, i64 0, i64 0
%68 = load i32, i32* %67
%69 = bitcast %union.anon* %5 to [2 x i32]*
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %69, i64 0, i64 1
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %50, i32 %53, i32 %56, i32 %59, i32 %62, i32 %65, i32 %68, i32 %71)
%73 = bitcast %union.anon* %2 to [2 x i32]*
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %73, i64 0, i64 0
%75 = load i32, i32* %74
%76 = bitcast %union.anon* %2 to [2 x i32]*
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %76, i64 0, i64 1
%78 = load i32, i32* %77
%79 = bitcast %union.anon* %3 to [2 x i32]*
%80 = getelementptr inbounds [2 x i32], [2 x i32]* %79, i64 0, i64 0
%81 = load i32, i32* %80
%82 = bitcast %union.anon* %3 to [2 x i32]*
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %82, i64 0, i64 1
%84 = load i32, i32* %83
%85 = bitcast %union.anon* %4 to [2 x i32]*
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %85, i64 0, i64 0
%87 = load i32, i32* %86
%88 = bitcast %union.anon* %4 to [2 x i32]*
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %88, i64 0, i64 1
%90 = load i32, i32* %89
%91 = bitcast %union.anon* %2 to [2 x i32]*
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %91, i64 0, i64 0
%93 = load i32, i32* %92
%94 = bitcast %union.anon* %2 to [2 x i32]*
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %94, i64 0, i64 1
%96 = load i32, i32* %95
%97 = bitcast %union.anon* %3 to [2 x i32]*
%98 = getelementptr inbounds [2 x i32], [2 x i32]* %97, i64 0, i64 0
%99 = load i32, i32* %98
%100 = bitcast %union.anon* %3 to [2 x i32]*
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %100, i64 0, i64 1
%102 = load i32, i32* %101
%103 = bitcast %union.anon* %5 to [2 x i32]*
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %103, i64 0, i64 0
%105 = load i32, i32* %104
%106 = bitcast %union.anon* %5 to [2 x i32]*
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %106, i64 0, i64 1
%108 = load i32, i32* %107
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %75, i32 %78, i32 %81, i32 %84, i32 %87, i32 %90, i32 %93, i32 %96, i32 %99, i32 %102, i32 %105, i32 %108)
br label %7
110: ; preds = %13
%111 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%union.anon = type { i64 }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [12 x i8] c"%u:%u %u:%u\00"
@.str.2 = [16 x i8] c"0x%x:%x 0x%x:%x\00"
@.str.4 = [36 x i8] c"%x:%x /%% %x:%x => q=%x:%x r=%x:%x\0A\00"
@.str.5 = [62 x i8] c" = %X%08X / %X%08X => %X%08X\0A = %X%08X %% %X%08X => %X%08X\0A\00"
@str = [4 x i8] c"eh?\00"
define i32 @main() {
%1 = alloca %union.anon
%2 = alloca %union.anon
%3 = alloca %union.anon
%4 = alloca [300 x i8]
%5 = bitcast %union.anon* %1 to i8*
%6 = bitcast %union.anon* %2 to i8*
%7 = bitcast %union.anon* %3 to i8*
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %8, i32 300, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %60, label %13
13: ; preds = %0
%14 = bitcast %union.anon* %1 to [2 x i32]*
%15 = bitcast %union.anon* %1 to i32*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
%17 = bitcast %union.anon* %2 to [2 x i32]*
%18 = bitcast %union.anon* %2 to i32*
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%20 = getelementptr inbounds %union.anon, %union.anon* %1, i64 0, i32 0
%21 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0
%22 = getelementptr inbounds %union.anon, %union.anon* %3, i64 0, i32 0
%23 = bitcast %union.anon* %3 to [2 x i32]*
%24 = bitcast %union.anon* %3 to i32*
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 1
br label %26
26: ; preds = %13, %34
%27 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %15, i32* %16, i32* %18, i32* %19)
%28 = icmp eq i32 %27, 4
br i1 %28, label %39, label %29
29: ; preds = %26
%30 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %15, i32* %16, i32* %18, i32* %19)
%31 = icmp eq i32 %30, 4
br i1 %31, label %39, label %32
32: ; preds = %29
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %32, %39
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* @stdin
%37 = call i32* @fgets(i8* %8, i32 300, i32 %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %60, label %26
39: ; preds = %29, %26
%40 = load i64, i64* %20
%41 = load i64, i64* %21
%42 = call i64 @__qdivrem(i64 %40, i64 %41, i64* %22)
%43 = trunc i64 %42 to i32
%44 = lshr i64 %42, 32
%45 = trunc i64 %44 to i32
%46 = load i32, i32* %15
%47 = load i32, i32* %16
%48 = load i32, i32* %18
%49 = load i32, i32* %19
%50 = load i32, i32* %24
%51 = load i32, i32* %25
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %47, i32 %48, i32 %49, i32 %43, i32 %45, i32 %50, i32 %51)
%53 = load i32, i32* %15
%54 = load i32, i32* %16
%55 = load i32, i32* %18
%56 = load i32, i32* %19
%57 = load i32, i32* %24
%58 = load i32, i32* %25
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %53, i32 %54, i32 %55, i32 %56, i32 %43, i32 %45, i32 %53, i32 %54, i32 %55, i32 %56, i32 %57, i32 %58)
br label %34
60: ; preds = %34, %0
%61 = call i32 @exit(i32 0)
unreachable
}