#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 */
struct node {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ DecimalToBitstring(unsigned int, struct node *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ DeleteList(struct node *);
int /*<<< orphan*/ EXIT_SUCCESS;
struct node *MakeNode(char, int /*<<< orphan*/ *);
unsigned int PerformModulation(unsigned int, struct node *, unsigned int,
                               int /*<<< orphan*/ *);
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 *,
                         unsigned int *);
int main() {
  unsigned b, n, m;
  unsigned result;
  struct node *head;
  char outputFilename[] = "Output.tex";
  FILE *outputFile = fopen(outputFilename, "w");
  head = MakeNode('z', NULL);
  printf("Enter b, n, and m: ");
  scanf("%u %u %u", &b, &n, &m);
  fprintf(outputFile, "\\(b\\) = %d, \\(n\\) = %d, \\(m\\) = %d\n", b, n, m);
  DecimalToBitstring(n, head, outputFile);
  fprintf(outputFile, "\\\\\n\n");
  result = PerformModulation(b, head, m, outputFile);
  fprintf(outputFile, "\nSo \\(%d^{%d} \\bmod %d = \\ans{%d}\\)", b, n, m,
          result);
  DeleteList(head);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x2b(%rbp)
mov    0xe57(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xe4f(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x2b(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    $0x7a,%edi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <MakeNode@plt>
mov    %rax,-0x20(%rbp)
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1070 <scanf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1040 <DecimalToBitstring@plt>
mov    -0x38(%rbp),%rdi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x38(%rbp),%rcx
call   1030 <PerformModulation@plt>
mov    %eax,-0x14(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <DeleteList@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x742e74757074754f,%rax
74 2e 74
mov    %rax,0x18(%rsp)
movl   $0x786574,0x1f(%rsp)
lea    0xe46(%rip),%rsi
lea    0x18(%rsp),%rdi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    $0x7a,%edi
xor    %esi,%esi
call   10c0 <MakeNode@plt>
mov    %rax,%r14
lea    0xe25(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2d(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1070 <scanf@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xe0e(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x10(%rsp),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <DecimalToBitstring@plt>
lea    0xe12(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10b0 <fwrite@plt>
mov    0x14(%rsp),%edi
mov    0xc(%rsp),%edx
mov    %r14,%rsi
mov    %rbx,%rcx
call   1030 <PerformModulation@plt>
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%r9d
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1080 <DeleteList@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.node = type { i32 }
@__const.main.outputFilename = [11 x i8] c"Output.tex\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [20 x i8] c"Enter b, n, and m: \00"
@.str.2 = [9 x i8] c"%u %u %u\00"
@.str.3 = [36 x i8] c"\\(b\\) = %d, \\(n\\) = %d, \\(m\\) = %d\0A\00"
@.str.4 = [5 x i8] c"\\\\\0A\0A\00"
@.str.5 = [36 x i8] c"\0ASo \\(%d^{%d} \\bmod %d = \\ans{%d}\\)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.node*
%7 = alloca [11 x i8]
%8 = alloca i32*
store i32 0, i32* %1
%9 = bitcast [11 x i8]* %7 to i8*
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %8
%12 = call %struct.node* @MakeNode(i8 signext 122, i32* null)
store %struct.node* %12, %struct.node** %6
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%15 = load i32*, i32** %8
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* %3
%21 = load %struct.node*, %struct.node** %6
%22 = load i32*, i32** %8
%23 = call i32 @DecimalToBitstring(i32 %20, %struct.node* %21, i32* %22)
%24 = load i32*, i32** %8
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = load %struct.node*, %struct.node** %6
%28 = load i32, i32* %4
%29 = load i32*, i32** %8
%30 = call i32 @PerformModulation(i32 %26, %struct.node* %27, i32 %28, i32* %29)
store i32 %30, i32* %5
%31 = load i32*, i32** %8
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %33, i32 %34, i32 %35)
%37 = load %struct.node*, %struct.node** %6
%38 = call i32 @DeleteList(%struct.node* %37)
%39 = load i32, i32* @EXIT_SUCCESS
%40 = call i32 @exit(i32 %39)
unreachable
}

LLVM IR (-O2):
%struct.node = type { i32 }
@__const.main.outputFilename = [11 x i8] c"Output.tex\00"
@.str = [2 x i8] c"w\00"
@.str.1 = [20 x i8] c"Enter b, n, and m: \00"
@.str.2 = [9 x i8] c"%u %u %u\00"
@.str.3 = [36 x i8] c"\\(b\\) = %d, \\(n\\) = %d, \\(m\\) = %d\0A\00"
@.str.4 = [5 x i8] c"\\\\\0A\0A\00"
@.str.5 = [36 x i8] c"\0ASo \\(%d^{%d} \\bmod %d = \\ans{%d}\\)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [11 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [11 x i8], [11 x i8]* %4, i64 0, i64 0
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call %struct.node* @MakeNode(i8 signext 122, i32* null)
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @DecimalToBitstring(i32 %17, %struct.node* %10, i32* %9)
%19 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i64 4, i64 1, i32* %9)
%20 = load i32, i32* %1
%21 = load i32, i32* %3
%22 = call i32 @PerformModulation(i32 %20, %struct.node* %10, i32 %21, i32* %9)
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %22)
%27 = call i32 @DeleteList(%struct.node* %10)
%28 = load i32, i32* @EXIT_SUCCESS
%29 = call i32 @exit(i32 %28)
unreachable
}