#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  int userint1;
  int userint2;
  int swap;
  double double1;
  double double2;
  system("clear");
  printf("Please enter an integer: ");
  scanf("%d", &userint1);
  printf("Please enter a second integer: ");
  scanf("%d", &userint2);
  if (userint2 > userint1) {
    swap = userint1;
    userint1 = userint2;
    userint2 = swap;
  }
  if (userint2 == 0) {
    printf("\nYou cannot divide by zero, program ending...\n\n");
    return (1);
  }
  printf("\n%d / %d = %d\n", userint1, userint2, (userint1 / userint2));
  printf("%d %% %d = %d\n", userint1, userint2, (userint1 % userint2));
  double1 = userint1;
  double2 = userint2;
  printf("%lf / %lf = %lf\n\n", double1, double2, (double1 / double2));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <system@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11ac <main+0x7c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11d0 <main+0xa0>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124c <main+0x11c>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    -0x38(%rbp),%edx
mov    %eax,%ecx
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,%ecx
mov    -0x34(%rbp),%edx
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
divsd  -0x30(%rbp),%xmm2
lea    0xe4c(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
call   1040 <system@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebc(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jle    11fc <main+0xbc>
mov    %eax,0x4(%rsp)
mov    %ecx,(%rsp)
mov    %eax,%esi
test   %ecx,%ecx
je     1204 <main+0xc4>
mov    %esi,%eax
cltd
idiv   %ecx
lea    0xe95(%rip),%rdi
xor    %ebp,%ebp
mov    %ecx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%ebx
mov    %esi,%eax
cltd
idiv   %ebx
mov    %edx,%ecx
lea    0xe82(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cvtsi2sdl 0x4(%rsp),%xmm0
cvtsi2sdl (%rsp),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xe6e(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    1215 <main+0xd5>
mov    %ecx,%esi
mov    %eax,%ecx
test   %ecx,%ecx
jne    11a2 <main+0x62>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [26 x i8] c"Please enter an integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Please enter a second integer: \00"
@.str.4 = [48 x i8] c"\0AYou cannot divide by zero, program ending...\0A\0A\00"
@.str.5 = [15 x i8] c"\0A%d / %d = %d\0A\00"
@.str.6 = [15 x i8] c"%d %% %d = %d\0A\00"
@.str.7 = [18 x i8] c"%lf / %lf = %lf\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %2
%20 = load i32, i32* %6
store i32 %20, i32* %8
%21 = load i32, i32* %7
store i32 %21, i32* %6
%22 = load i32, i32* %8
store i32 %22, i32* %7
br label %23
23: ; preds = %19, %2
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %51
28: ; preds = %23
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = sdiv i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %30, i32 %33)
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = srem i32 %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %35, i32 %36, i32 %39)
%41 = load i32, i32* %6
%42 = sitofp i32 %41 to double
store double %42, double* %9
%43 = load i32, i32* %7
%44 = sitofp i32 %43 to double
store double %44, double* %10
%45 = load double, double* %9
%46 = load double, double* %10
%47 = load double, double* %9
%48 = load double, double* %10
%49 = fdiv double %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), double %45, double %46, double %49)
br label %51
51: ; preds = %28, %26
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.1 = [26 x i8] c"Please enter an integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [32 x i8] c"Please enter a second integer: \00"
@.str.5 = [15 x i8] c"\0A%d / %d = %d\0A\00"
@.str.6 = [15 x i8] c"%d %% %d = %d\0A\00"
@.str.7 = [18 x i8] c"%lf / %lf = %lf\0A\0A\00"
@str = [47 x i8] c"\0AYou cannot divide by zero, program ending...\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp sgt i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 %12, i32* %3
store i32 %13, i32* %4
br label %16
16: ; preds = %15, %2
%17 = phi i32 [ %12, %15 ], [ %13, %2 ]
%18 = phi i32 [ %13, %15 ], [ %12, %2 ]
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %35
22: ; preds = %16
%23 = sdiv i32 %17, %18
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %17, i32 %18, i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = srem i32 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %25, i32 %26, i32 %27)
%29 = load i32, i32* %3
%30 = sitofp i32 %29 to double
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to double
%33 = fdiv double %30, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), double %30, double %32, double %33)
br label %35
35: ; preds = %22, %20
%36 = phi i32 [ 1, %20 ], [ 0, %22 ]
ret i32 %36
}