#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 */
scalar_t__ divisible(int, scalar_t__);
scalar_t__ first_two(int);
scalar_t__ last_two(int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int i;
  int count = 0;
  for (i = 1000; i <= 9999; ++i) {
    if (divisible(i, first_two(i) + last_two(i))) {
      printf("%d\n", i);
      ++count;
    }
  }
  printf("Total: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x3e8,-0x8(%rbp)
cmpl   $0x270f,-0x8(%rbp)
jg     11c8 <main+0x88>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <first_two@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <last_two@plt>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edi
add    %rax,%rsi
call   1050 <divisible@plt>
cmp    $0x0,%rax
je     11b5 <main+0x75>
mov    -0x8(%rbp),%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ba <main+0x7a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x3e8,%ebp
xor    %r15d,%r15d
lea    0xeb1(%rip),%r14
jmp    116b <main+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x2710,%ebp
je     119e <main+0x5e>
mov    %ebp,%edi
call   1040 <first_two@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1060 <last_two@plt>
add    %rax,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <divisible@plt>
test   %rax,%rax
je     1160 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r15d
jmp    1160 <main+0x20>
lea    0xe5b(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1000, i32* %2
br label %4
4: ; preds = %22, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 9999
br i1 %6, label %7, label %25
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = call i64 @first_two(i32 %9)
%11 = load i32, i32* %2
%12 = call i64 @last_two(i32 %11)
%13 = add nsw i64 %10, %12
%14 = call i64 @divisible(i32 %8, i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %7
%17 = load i32, i32* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %21
21: ; preds = %16, %7
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %4
25: ; preds = %4
%26 = load i32, i32* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [11 x i8] c"Total: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %12
%2 = phi i32 [ 0, %0 ], [ %13, %12 ]
%3 = phi i32 [ 1000, %0 ], [ %14, %12 ]
%4 = tail call i64 @first_two(i32 %3)
%5 = tail call i64 @last_two(i32 %3)
%6 = add nsw i64 %5, %4
%7 = tail call i64 @divisible(i32 %3, i64 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%11 = add nsw i32 %2, 1
br label %12
12: ; preds = %1, %9
%13 = phi i32 [ %11, %9 ], [ %2, %1 ]
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 10000
br i1 %15, label %16, label %1
16: ; preds = %12
%17 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %13)
ret i32 0
}