#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 */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *, unsigned int *);
main() {
  unsigned FindGCD(unsigned a, unsigned b, FILE *outputFile);
  unsigned a;
  unsigned b;
  unsigned result;
  FILE *outputFile = fopen("Output.tex", "w");
  printf("Enter two unsigned integers:\n");
  scanf("%u %u", &a, &b);
  fprintf(outputFile, "\\begin{align*}\n");
  result = FindGCD(a, b, outputFile);
  fprintf(outputFile, "\\end{align*}\n");
  fprintf(outputFile, "The last nonzero remainder is \\(%d\\).\\\\\n", result);
  fprintf(outputFile, "So the GCD of $%d$ and $%d$ is \\highlight{\\(%d\\)}.",
          a, b, result);
  printf("%d\n", result);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1050 <FindGCD@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe76(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe61(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <scanf@plt>
lea    0xe53(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
mov    %rbx,%rdx
call   1060 <FindGCD@plt>
mov    %eax,%ebp
lea    0xe39(%rip),%rdi
mov    $0xd,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe5c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Output.tex\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"Enter two unsigned integers:\0A\00"
@.str.3 = [6 x i8] c"%u %u\00"
@.str.4 = [16 x i8] c"\\begin{align*}\0A\00"
@.str.5 = [14 x i8] c"\\end{align*}\0A\00"
@.str.6 = [41 x i8] c"The last nonzero remainder is \\(%d\\).\\\\\0A\00"
@.str.7 = [51 x i8] c"So the GCD of $%d$ and $%d$ is \\highlight{\\(%d\\)}.\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32*, i32** %5
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = load i32*, i32** %5
%14 = call i32 @FindGCD(i32 %11, i32 %12, i32* %13)
store i32 %14, i32* %4
%15 = load i32*, i32** %5
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%17 = load i32*, i32** %5
%18 = load i32, i32* %4
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %5
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"Output.tex\00"
@.str.1 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"%u %u\00"
@.str.4 = [16 x i8] c"\\begin{align*}\0A\00"
@.str.5 = [14 x i8] c"\\end{align*}\0A\00"
@.str.6 = [41 x i8] c"The last nonzero remainder is \\(%d\\).\\\\\0A\00"
@.str.7 = [51 x i8] c"So the GCD of $%d$ and $%d$ is \\highlight{\\(%d\\)}.\00"
@.str.8 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [29 x i8] c"Enter two unsigned integers:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2)
%8 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 15, i64 1, i32* %5)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = call i32 @FindGCD(i32 %9, i32 %10, i32* %5)
%12 = call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 13, i64 1, i32* %5)
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 %11)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %14, i32 %15, i32 %11)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %11)
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @exit(i32 %18)
unreachable
}