#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 divisionByReference(int *, int *);
int divisionByValue(int, int);
int /*<<< orphan*/ printf(char *, int);
void runDivision() {
  int c = 20, d = 10, total = 0;
  int *dividend;
  int *divisor;
  dividend = &c;
  divisor = &d;
  total = divisionByValue(c, d);
  printf("Division is %d\n", total);
  *dividend = 2000;
  total = divisionByReference(dividend, divisor);
  printf("Division is %d\n", total);
}


x86 assembly (clang, -O0):
<runDivision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x14,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <divisionByValue@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0x7d0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <divisionByReference@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runDivision>:
push   %rbx
sub    $0x10,%rsp
movl   $0xa,0x8(%rsp)
mov    $0x14,%edi
mov    $0xa,%esi
call   1030 <divisionByValue@plt>
lea    0xead(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
movl   $0x7d0,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <divisionByReference@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Division is %d\0A\00"
define void @runDivision() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 20, i32* %1
store i32 10, i32* %2
store i32 0, i32* %3
store i32* %1, i32** %4
store i32* %2, i32** %5
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = call i32 @divisionByValue(i32 %6, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32*, i32** %4
store i32 2000, i32* %11
%12 = load i32*, i32** %4
%13 = load i32*, i32** %5
%14 = call i32 @divisionByReference(i32* %12, i32* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Division is %d\0A\00"
define void @runDivision() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 10, i32* %2
%5 = tail call i32 @divisionByValue(i32 20, i32 10)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 2000, i32* %1
%7 = call i32 @divisionByReference(i32* %1, i32* %2)
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7)
ret void
}