#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 fun(int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, b, c, m, i, sum = 0;
  scanf("%d", &m);
  for (a = 0; a <= 1111; a++) {
    for (b = 0; b <= 1111; ++b) {
      c = a + b;
      if (fun(a) + fun(b) + fun(c) == m - 4) {
        printf("%d + %d = %d \n", a, b, c);
        sum++;
      }
    }
  }
  printf("total:%d", sum);
  getchar();
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x457,-0x8(%rbp)
jg     1217 <main+0xd7>
movl   $0x0,-0xc(%rbp)
cmpl   $0x457,-0xc(%rbp)
jg     1204 <main+0xc4>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    -0x14(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jne    11f1 <main+0xb1>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <main+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1181 <main+0x41>
jmp    1209 <main+0xc9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x2d>
mov    -0x1c(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    117d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12d
cmp    $0x458,%r12d
je     11e8 <main+0xa8>
xor    %ebp,%ebp
jmp    119b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x458,%ebp
je     1170 <main+0x30>
lea    (%r12,%rbp,1),%r13d
mov    %r12d,%edi
call   1030 <fun@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1030 <fun@plt>
mov    %eax,%r14d
add    %ebx,%r14d
mov    %r13d,%edi
call   1030 <fun@plt>
add    %r14d,%eax
mov    0x4(%rsp),%ecx
add    $0xfffffffc,%ecx
cmp    %ecx,%eax
jne    1190 <main+0x50>
lea    0xe2d(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
jmp    1190 <main+0x50>
lea    0xe20(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"%d + %d = %d \0A\00"
@.str.2 = [9 x i8] c"total:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %2
br label %9
9: ; preds = %43, %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 1111
br i1 %11, label %12, label %46
12: ; preds = %9
store i32 0, i32* %3
br label %13
13: ; preds = %39, %12
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 1111
br i1 %15, label %16, label %42
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = add nsw i32 %17, %18
store i32 %19, i32* %4
%20 = load i32, i32* %2
%21 = call i32 @fun(i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @fun(i32 %22)
%24 = add nsw i32 %21, %23
%25 = load i32, i32* %4
%26 = call i32 @fun(i32 %25)
%27 = add nsw i32 %24, %26
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 4
%30 = icmp eq i32 %27, %29
br i1 %30, label %31, label %38
31: ; preds = %16
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %38
38: ; preds = %31, %16
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %13
42: ; preds = %13
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %9
46: ; preds = %9
%47 = load i32, i32* %7
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = call i32 (...) @getchar()
%50 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [15 x i8] c"%d + %d = %d \0A\00"
@.str.2 = [9 x i8] c"total:%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %4
4: ; preds = %0, %26
%5 = phi i32 [ 0, %0 ], [ %23, %26 ]
%6 = phi i32 [ 0, %0 ], [ %27, %26 ]
br label %7
7: ; preds = %4, %22
%8 = phi i32 [ %5, %4 ], [ %23, %22 ]
%9 = phi i32 [ 0, %4 ], [ %24, %22 ]
%10 = add nuw nsw i32 %9, %6
%11 = call i32 @fun(i32 %6)
%12 = call i32 @fun(i32 %9)
%13 = add nsw i32 %12, %11
%14 = call i32 @fun(i32 %10)
%15 = add nsw i32 %13, %14
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -4
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %22
19: ; preds = %7
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %9, i32 %10)
%21 = add nsw i32 %8, 1
br label %22
22: ; preds = %7, %19
%23 = phi i32 [ %21, %19 ], [ %8, %7 ]
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, 1112
br i1 %25, label %26, label %7
26: ; preds = %22
%27 = add nuw nsw i32 %6, 1
%28 = icmp eq i32 %27, 1112
br i1 %28, label %29, label %4
29: ; preds = %26
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%31 = call i32 (...) @getchar()
%32 = call i32 (...) @getchar()
ret i32 0
}