#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, m;
  char buf[300];
  extern long long __muldi3(long long, 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;
    }
    m.q = __muldi3(a.q, b.q);
    printf("%x:%x * %x:%x => %x:%x\n", a.v[0], a.v[1], b.v[0], b.v[1], m.v[0],
           m.v[1]);
    printf("  = %X%08X * %X%08X => %X%08X\n", a.v[0], a.v[1], b.v[0], b.v[1],
           m.v[0], m.v[1]);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x150(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    $0x12c,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1199 <main+0x49>
jmp    1274 <main+0x124>
lea    -0x150(%rbp),%rdi
lea    -0x10(%rbp),%rdx
lea    -0x10(%rbp),%rcx
add    $0x4,%rcx
lea    -0x18(%rbp),%r8
lea    -0x18(%rbp),%r9
add    $0x4,%r9
lea    0xe44(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x4,%eax
je     1214 <main+0xc4>
lea    -0x150(%rbp),%rdi
lea    -0x10(%rbp),%rdx
lea    -0x10(%rbp),%rcx
add    $0x4,%rcx
lea    -0x18(%rbp),%r8
lea    -0x18(%rbp),%r9
add    $0x4,%r9
lea    0xe1c(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x4,%eax
je     1214 <main+0xc4>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <main+0x12>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <__muldi3@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xde4(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xdd7(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <main+0x12>
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   1050 <fgets@plt>
test   %rax,%rax
jne    11a3 <main+0x43>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0x14(%rsp),%rbp
lea    0x1c(%rsp),%rbx
lea    0x20(%rsp),%r12
lea    0x10(%rsp),%r14
lea    0x18(%rsp),%r13
jmp    1273 <main+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
call   1070 <__muldi3@plt>
mov    %r12,%rbp
mov    %r14,%r12
mov    %rax,%r14
mov    %rax,%r15
shr    $0x20,%r15
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    %r15d,(%rsp)
lea    0xe14(%rip),%rdi
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x1c(%rsp),%r8d
mov    %r15d,(%rsp)
lea    0xe06(%rip),%rdi
mov    %r14d,%r9d
mov    %r12,%r14
mov    %rbp,%r12
lea    0x14(%rsp),%rbp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    $0x12c,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     119c <main+0x3c>
mov    %r12,%rdi
lea    0xd86(%rip),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
mov    %r12,%rdi
lea    0xd6e(%rip),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
mov    %r13,%r8
mov    %rbx,%r9
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
lea    0xd94(%rip),%rdi
call   1030 <puts@plt>
jmp    1246 <main+0xe6>

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 = [24 x i8] c"%x:%x * %x:%x => %x:%x\0A\00"
@.str.5 = [31 x i8] c" = %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 [300 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %39, %37, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %8, i32 300, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %6
br label %84
13: ; preds = %6
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%15 = bitcast %union.anon* %2 to [2 x i32]*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 0
%17 = bitcast %union.anon* %2 to [2 x i32]*
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%19 = bitcast %union.anon* %3 to [2 x i32]*
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %19, i64 0, i64 0
%21 = bitcast %union.anon* %3 to [2 x i32]*
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %21, i64 0, i64 1
%23 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %16, i32* %18, i32* %20, i32* %22)
%24 = icmp ne i32 %23, 4
br i1 %24, label %25, label %39
25: ; preds = %13
%26 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%27 = bitcast %union.anon* %2 to [2 x i32]*
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %27, i64 0, i64 0
%29 = bitcast %union.anon* %2 to [2 x i32]*
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %29, i64 0, i64 1
%31 = bitcast %union.anon* %3 to [2 x i32]*
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %31, i64 0, i64 0
%33 = bitcast %union.anon* %3 to [2 x i32]*
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %33, i64 0, i64 1
%35 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %28, i32* %30, i32* %32, i32* %34)
%36 = icmp ne i32 %35, 4
br i1 %36, label %37, label %39
37: ; preds = %25
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %6
39: ; preds = %25, %13
%40 = bitcast %union.anon* %2 to i64*
%41 = load i64, i64* %40
%42 = bitcast %union.anon* %3 to i64*
%43 = load i64, i64* %42
%44 = call i64 @__muldi3(i64 %41, i64 %43)
%45 = bitcast %union.anon* %4 to i64*
store i64 %44, i64* %45
%46 = bitcast %union.anon* %2 to [2 x i32]*
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %46, i64 0, i64 0
%48 = load i32, i32* %47
%49 = bitcast %union.anon* %2 to [2 x i32]*
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %49, i64 0, i64 1
%51 = load i32, i32* %50
%52 = bitcast %union.anon* %3 to [2 x i32]*
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %52, i64 0, i64 0
%54 = load i32, i32* %53
%55 = bitcast %union.anon* %3 to [2 x i32]*
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %55, i64 0, i64 1
%57 = load i32, i32* %56
%58 = bitcast %union.anon* %4 to [2 x i32]*
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %58, i64 0, i64 0
%60 = load i32, i32* %59
%61 = bitcast %union.anon* %4 to [2 x i32]*
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %61, i64 0, i64 1
%63 = load i32, i32* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 %51, i32 %54, i32 %57, i32 %60, i32 %63)
%65 = bitcast %union.anon* %2 to [2 x i32]*
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %65, i64 0, i64 0
%67 = load i32, i32* %66
%68 = bitcast %union.anon* %2 to [2 x i32]*
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %68, i64 0, i64 1
%70 = load i32, i32* %69
%71 = bitcast %union.anon* %3 to [2 x i32]*
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %71, i64 0, i64 0
%73 = load i32, i32* %72
%74 = bitcast %union.anon* %3 to [2 x i32]*
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %74, i64 0, i64 1
%76 = load i32, i32* %75
%77 = bitcast %union.anon* %4 to [2 x i32]*
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %77, i64 0, i64 0
%79 = load i32, i32* %78
%80 = bitcast %union.anon* %4 to [2 x i32]*
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %80, i64 0, i64 1
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %67, i32 %70, i32 %73, i32 %76, i32 %79, i32 %82)
br label %6
84: ; preds = %12
%85 = 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 = [24 x i8] c"%x:%x * %x:%x => %x:%x\0A\00"
@.str.5 = [31 x i8] c" = %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 [300 x i8]
%4 = bitcast %union.anon* %1 to i8*
%5 = bitcast %union.anon* %2 to i8*
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %6, i32 300, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %50, label %11
11: ; preds = %0
%12 = bitcast %union.anon* %1 to [2 x i32]*
%13 = bitcast %union.anon* %1 to i32*
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%15 = bitcast %union.anon* %2 to [2 x i32]*
%16 = bitcast %union.anon* %2 to i32*
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %15, i64 0, i64 1
%18 = getelementptr inbounds %union.anon, %union.anon* %1, i64 0, i32 0
%19 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0
br label %20
20: ; preds = %11, %28
%21 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %13, i32* %14, i32* %16, i32* %17)
%22 = icmp eq i32 %21, 4
br i1 %22, label %33, label %23
23: ; preds = %20
%24 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %13, i32* %14, i32* %16, i32* %17)
%25 = icmp eq i32 %24, 4
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %26, %33
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @stdin
%31 = call i32* @fgets(i8* %6, i32 300, i32 %30)
%32 = icmp eq i32* %31, null
br i1 %32, label %50, label %20
33: ; preds = %23, %20
%34 = load i64, i64* %18
%35 = load i64, i64* %19
%36 = call i64 @__muldi3(i64 %34, i64 %35)
%37 = trunc i64 %36 to i32
%38 = lshr i64 %36, 32
%39 = trunc i64 %38 to i32
%40 = load i32, i32* %13
%41 = load i32, i32* %14
%42 = load i32, i32* %16
%43 = load i32, i32* %17
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %37, i32 %39)
%45 = load i32, i32* %13
%46 = load i32, i32* %14
%47 = load i32, i32* %16
%48 = load i32, i32* %17
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 %46, i32 %47, i32 %48, i32 %37, i32 %39)
br label %28
50: ; preds = %28, %0
%51 = call i32 @exit(i32 0)
unreachable
}