#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*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int m, a, b, c, 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("all total=%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x457,-0xc(%rbp)
jg     1207 <main+0xd7>
movl   $0x0,-0x10(%rbp)
cmpl   $0x457,-0x10(%rbp)
jg     11f4 <main+0xc4>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <fun@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    -0x8(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jne    11e1 <main+0xb1>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <main+0xb6>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1171 <main+0x41>
jmp    11f9 <main+0xc9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x2d>
mov    -0x18(%rbp),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    116d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12d
cmp    $0x458,%r12d
je     11d8 <main+0xa8>
xor    %ebp,%ebp
jmp    118b <main+0x5b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x458,%ebp
je     1160 <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    1180 <main+0x50>
lea    0xe3d(%rip),%rdi
mov    %r12d,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15d
jmp    1180 <main+0x50>
lea    0xe2b(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@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 = [10 x i8] c"%d+%d=%d\0A\00"
@.str.2 = [13 x i8] c"all total=%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %42, %0
%9 = load i32, i32* %3
%10 = icmp sle i32 %9, 1111
br i1 %10, label %11, label %45
11: ; preds = %8
store i32 0, i32* %4
br label %12
12: ; preds = %38, %11
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 1111
br i1 %14, label %15, label %41
15: ; preds = %12
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = add nsw i32 %16, %17
store i32 %18, i32* %5
%19 = load i32, i32* %3
%20 = call i32 @fun(i32 %19)
%21 = load i32, i32* %4
%22 = call i32 @fun(i32 %21)
%23 = add nsw i32 %20, %22
%24 = load i32, i32* %5
%25 = call i32 @fun(i32 %24)
%26 = add nsw i32 %23, %25
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 4
%29 = icmp eq i32 %26, %28
br i1 %29, label %30, label %37
30: ; preds = %15
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %37
37: ; preds = %30, %15
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %12
41: ; preds = %12
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %8
45: ; preds = %8
%46 = load i32, i32* %6
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%d+%d=%d\0A\00"
@.str.2 = [13 x i8] c"all 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 ([10 x i8], [10 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 ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret i32 0
}