#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 long *, unsigned long *, unsigned long *,
           unsigned long *);
int /*<<< orphan*/ stdin;
main() {
  union {
    long long q;
    unsigned long 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, "%lu:%lu %lu:%lu", &a.v[0], &a.v[1], &b.v[0], &b.v[1]) !=
            4 &&
        sscanf(buf, "0x%lx:%lx 0x%lx:%lx", &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("%lx:%lx * %lx:%lx => %lx:%lx\n", a.v[0], a.v[1], b.v[0], b.v[1],
           m.v[0], m.v[1]);
    printf("  = %lX%08lX * %lX%08lX => %lX%08lX\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    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x170(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%edx
mov    $0x12c,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    1199 <main+0x49>
jmp    127e <main+0x12e>
lea    -0x170(%rbp),%rdi
lea    -0x18(%rbp),%rdx
lea    -0x18(%rbp),%rcx
add    $0x8,%rcx
lea    -0x28(%rbp),%r8
lea    -0x28(%rbp),%r9
add    $0x8,%r9
lea    0xe44(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x4,%eax
je     1214 <main+0xc4>
lea    -0x170(%rbp),%rdi
lea    -0x18(%rbp),%rdx
lea    -0x18(%rbp),%rcx
add    $0x8,%rcx
lea    -0x28(%rbp),%r8
lea    -0x28(%rbp),%r9
add    $0x8,%r9
lea    0xe20(%rip),%rsi
call   1050 <sscanf@plt>
cmp    $0x4,%eax
je     1214 <main+0xc4>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1162 <main+0x12>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <__muldi3@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x30(%rbp),%rax
lea    0xde8(%rip),%rdi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x30(%rbp),%rax
lea    0xddc(%rip),%rdi
mov    %rax,(%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    $0x168,%rsp
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rdi
mov    $0x12c,%esi
call   1050 <fgets@plt>
test   %rax,%rax
jne    11a3 <main+0x43>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0x28(%rsp),%r14
lea    0x18(%rsp),%r12
lea    0x30(%rsp),%rbx
lea    0x20(%rsp),%r13
lea    0x10(%rsp),%rbp
jmp    1259 <main+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rdi
mov    0x10(%rsp),%rsi
call   1070 <__muldi3@plt>
mov    %rax,%r15
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
lea    0xe2a(%rip),%rdi
mov    %rax,%r9
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%r8
lea    0xe23(%rip),%rdi
mov    %r15,%r9
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x12c,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     119c <main+0x3c>
mov    %rbx,%rdi
lea    0xda0(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %rbp,%r8
mov    %r12,%r9
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
mov    %rbx,%rdi
lea    0xd8c(%rip),%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %rbp,%r8
mov    %r12,%r9
call   1060 <sscanf@plt>
cmp    $0x4,%eax
je     11d0 <main+0x70>
lea    0xdc2(%rip),%rdi
call   1030 <puts@plt>
jmp    122c <main+0xcc>

LLVM IR (-O0):
%union.anon = type { [2 x i64] }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"%lu:%lu %lu:%lu\00"
@.str.2 = [20 x i8] c"0x%lx:%lx 0x%lx:%lx\00"
@.str.3 = [5 x i8] c"eh?\0A\00"
@.str.4 = [30 x i8] c"%lx:%lx * %lx:%lx => %lx:%lx\0A\00"
@.str.5 = [37 x i8] c" = %lX%08lX * %lX%08lX => %lX%08lX\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 i64]*
%16 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%17 = bitcast %union.anon* %2 to [2 x i64]*
%18 = getelementptr inbounds [2 x i64], [2 x i64]* %17, i64 0, i64 1
%19 = bitcast %union.anon* %3 to [2 x i64]*
%20 = getelementptr inbounds [2 x i64], [2 x i64]* %19, i64 0, i64 0
%21 = bitcast %union.anon* %3 to [2 x i64]*
%22 = getelementptr inbounds [2 x i64], [2 x i64]* %21, i64 0, i64 1
%23 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64* %16, i64* %18, i64* %20, i64* %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 i64]*
%28 = getelementptr inbounds [2 x i64], [2 x i64]* %27, i64 0, i64 0
%29 = bitcast %union.anon* %2 to [2 x i64]*
%30 = getelementptr inbounds [2 x i64], [2 x i64]* %29, i64 0, i64 1
%31 = bitcast %union.anon* %3 to [2 x i64]*
%32 = getelementptr inbounds [2 x i64], [2 x i64]* %31, i64 0, i64 0
%33 = bitcast %union.anon* %3 to [2 x i64]*
%34 = getelementptr inbounds [2 x i64], [2 x i64]* %33, i64 0, i64 1
%35 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64* %28, i64* %30, i64* %32, i64* %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 i64]*
%47 = getelementptr inbounds [2 x i64], [2 x i64]* %46, i64 0, i64 0
%48 = load i64, i64* %47
%49 = bitcast %union.anon* %2 to [2 x i64]*
%50 = getelementptr inbounds [2 x i64], [2 x i64]* %49, i64 0, i64 1
%51 = load i64, i64* %50
%52 = bitcast %union.anon* %3 to [2 x i64]*
%53 = getelementptr inbounds [2 x i64], [2 x i64]* %52, i64 0, i64 0
%54 = load i64, i64* %53
%55 = bitcast %union.anon* %3 to [2 x i64]*
%56 = getelementptr inbounds [2 x i64], [2 x i64]* %55, i64 0, i64 1
%57 = load i64, i64* %56
%58 = bitcast %union.anon* %4 to [2 x i64]*
%59 = getelementptr inbounds [2 x i64], [2 x i64]* %58, i64 0, i64 0
%60 = load i64, i64* %59
%61 = bitcast %union.anon* %4 to [2 x i64]*
%62 = getelementptr inbounds [2 x i64], [2 x i64]* %61, i64 0, i64 1
%63 = load i64, i64* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %48, i64 %51, i64 %54, i64 %57, i64 %60, i64 %63)
%65 = bitcast %union.anon* %2 to [2 x i64]*
%66 = getelementptr inbounds [2 x i64], [2 x i64]* %65, i64 0, i64 0
%67 = load i64, i64* %66
%68 = bitcast %union.anon* %2 to [2 x i64]*
%69 = getelementptr inbounds [2 x i64], [2 x i64]* %68, i64 0, i64 1
%70 = load i64, i64* %69
%71 = bitcast %union.anon* %3 to [2 x i64]*
%72 = getelementptr inbounds [2 x i64], [2 x i64]* %71, i64 0, i64 0
%73 = load i64, i64* %72
%74 = bitcast %union.anon* %3 to [2 x i64]*
%75 = getelementptr inbounds [2 x i64], [2 x i64]* %74, i64 0, i64 1
%76 = load i64, i64* %75
%77 = bitcast %union.anon* %4 to [2 x i64]*
%78 = getelementptr inbounds [2 x i64], [2 x i64]* %77, i64 0, i64 0
%79 = load i64, i64* %78
%80 = bitcast %union.anon* %4 to [2 x i64]*
%81 = getelementptr inbounds [2 x i64], [2 x i64]* %80, i64 0, i64 1
%82 = load i64, i64* %81
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i64 %67, i64 %70, i64 %73, i64 %76, i64 %79, i64 %82)
br label %6
84: ; preds = %12
%85 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%union.anon = type { [2 x i64] }
@.str = [3 x i8] c"> \00"
@stdin = global i32 0
@.str.1 = [16 x i8] c"%lu:%lu %lu:%lu\00"
@.str.2 = [20 x i8] c"0x%lx:%lx 0x%lx:%lx\00"
@.str.4 = [30 x i8] c"%lx:%lx * %lx:%lx => %lx:%lx\0A\00"
@.str.5 = [37 x i8] c" = %lX%08lX * %lX%08lX => %lX%08lX\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 %43, label %11
11: ; preds = %0
%12 = getelementptr inbounds %union.anon, %union.anon* %1, i64 0, i32 0, i64 0
%13 = getelementptr inbounds %union.anon, %union.anon* %1, i64 0, i32 0, i64 1
%14 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0, i64 0
%15 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0, i64 1
br label %16
16: ; preds = %11, %24
%17 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64* %12, i64* %13, i64* %14, i64* %15)
%18 = icmp eq i32 %17, 4
br i1 %18, label %29, label %19
19: ; preds = %16
%20 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i64* %12, i64* %13, i64* %14, i64* %15)
%21 = icmp eq i32 %20, 4
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %29
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = call i32* @fgets(i8* %6, i32 300, i32 %26)
%28 = icmp eq i32* %27, null
br i1 %28, label %43, label %16
29: ; preds = %19, %16
%30 = load i64, i64* %12
%31 = load i64, i64* %14
%32 = call i64 @__muldi3(i64 %30, i64 %31)
%33 = load i64, i64* %12
%34 = load i64, i64* %13
%35 = load i64, i64* %14
%36 = load i64, i64* %15
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %33, i64 %34, i64 %35, i64 %36, i64 %32, i64 undef)
%38 = load i64, i64* %12
%39 = load i64, i64* %13
%40 = load i64, i64* %14
%41 = load i64, i64* %15
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i64 %38, i64 %39, i64 %40, i64 %41, i64 %32, i64 undef)
br label %24
43: ; preds = %24, %0
%44 = call i32 @exit(i32 0)
unreachable
}