#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 digit_sum(int);
int /*<<< orphan*/ get_integer(char *, int *);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int x;
  printf("Digit sum - another exciting program\n");
  printf("    from Furball Enterprises, Inc,\n");
  printf("*** The new and improved version! ***\n\n");
  get_integer("Enter and integer: ", &x);
  printf("Sum of the digits of %d is %d.\n", x, digit_sum(x));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf09(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1030 <get_integer@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <digit_sum@plt>
mov    -0x8(%rbp),%esi
mov    %eax,%edx
lea    0xefa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf01(%rip),%rdi
call   1030 <puts@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <get_integer@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
call   1060 <digit_sum@plt>
lea    0xe88(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Digit sum - another exciting program\0A\00"
@.str.1 = [36 x i8] c" from Furball Enterprises, Inc,\0A\00"
@.str.2 = [40 x i8] c"*** The new and improved version! ***\0A\0A\00"
@.str.3 = [20 x i8] c"Enter and integer: \00"
@.str.4 = [32 x i8] c"Sum of the digits of %d is %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @get_integer(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = load i32, i32* %1
%8 = call i32 @digit_sum(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %6, i32 %8)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [20 x i8] c"Enter and integer: \00"
@.str.4 = [32 x i8] c"Sum of the digits of %d is %d.\0A\00"
@str = [37 x i8] c"Digit sum - another exciting program\00"
@str.5 = [35 x i8] c" from Furball Enterprises, Inc,\00"
@str.6 = [39 x i8] c"*** The new and improved version! ***\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.6, i64 0, i64 0))
%6 = call i32 @get_integer(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = call i32 @digit_sum(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %7, i32 %8)
ret i32 0
}