#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int bilboNum, gollumNum;
  int minor, major;
  printf("Digite os números de Bilbo e Gollum, respectivamente:\n");
  scanf("%d %d", &bilboNum, &gollumNum);
  minor = (bilboNum < gollumNum) ? bilboNum : gollumNum;
  major = (bilboNum < gollumNum) ? gollumNum : bilboNum;
  int sum = minor;
  int sumQtt = 1;
  printf("%d", minor);
  do {
    sum += minor + sumQtt;
    printf(" + %d", (minor + sumQtt));
    sumQtt++;
  } while (sum < major);
  printf(" = %d\n", sum);
  printf("%d numeros somados.\n", sumQtt);
  printf("Se %d for par, Bilbo vence; mas se for ímpar, Gollum venceu.\n",
         sumQtt);
  printf("Logo %s venceu!\n", (sumQtt % 2) ? "Gollum" : "Bilbo");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1168 <main+0x48>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    116e <main+0x4e>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118b <main+0x6b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1191 <main+0x71>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
add    -0x1c(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     11b5 <main+0x95>
mov    -0x18(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
lea    0xe88(%rip),%rsi
lea    0xe7a(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf42(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0xc(%rsp),%r12d
mov    0x8(%rsp),%eax
cmp    %eax,%r12d
mov    %eax,%r14d
cmovl  %r12d,%r14d
cmovl  %eax,%r12d
lea    0xe8d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
lea    0xe74(%rip),%r15
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbx,1),%esi
add    %esi,%ebp
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    %r12d,%ebp
jl     11a0 <main+0x70>
lea    0xe4d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
lea    0xe8d(%rip),%rax
lea    0xe7f(%rip),%rsi
cmove  %rax,%rsi
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Digite os n\C3\BAmeros de Bilbo e Gollum, respectivamente:\0A\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c" + %d\00"
@.str.4 = [7 x i8] c" = %d\0A\00"
@.str.5 = [21 x i8] c"%d numeros somados.\0A\00"
@.str.6 = [63 x i8] c"Se %d for par, Bilbo vence; mas se for \C3\ADmpar, Gollum venceu.\0A\00"
@.str.7 = [17 x i8] c"Logo %s venceu!\0A\00"
@.str.8 = [7 x i8] c"Gollum\00"
@.str.9 = [6 x i8] c"Bilbo\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
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = load i32, i32* %2
br label %17
15: ; preds = %0
%16 = load i32, i32* %3
br label %17
17: ; preds = %15, %13
%18 = phi i32 [ %14, %13 ], [ %16, %15 ]
store i32 %18, i32* %4
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i32, i32* %3
br label %26
24: ; preds = %17
%25 = load i32, i32* %2
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ %23, %22 ], [ %25, %24 ]
store i32 %27, i32* %5
%28 = load i32, i32* %4
store i32 %28, i32* %6
store i32 1, i32* %7
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %43, %26
%32 = load i32, i32* %4
%33 = load i32, i32* %7
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, %34
store i32 %36, i32* %6
%37 = load i32, i32* %4
%38 = load i32, i32* %7
%39 = add nsw i32 %37, %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %43
43: ; preds = %31
%44 = load i32, i32* %6
%45 = load i32, i32* %5
%46 = icmp slt i32 %44, %45
br i1 %46, label %31, label %47
47: ; preds = %43
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %7
%55 = srem i32 %54, 2
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %58)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c" + %d\00"
@.str.4 = [7 x i8] c" = %d\0A\00"
@.str.5 = [21 x i8] c"%d numeros somados.\0A\00"
@.str.6 = [63 x i8] c"Se %d for par, Bilbo vence; mas se for \C3\ADmpar, Gollum venceu.\0A\00"
@.str.7 = [17 x i8] c"Logo %s venceu!\0A\00"
@.str.8 = [7 x i8] c"Gollum\00"
@.str.9 = [6 x i8] c"Bilbo\00"
@str = [55 x i8] c"Digite os n\C3\BAmeros de Bilbo e Gollum, respectivamente:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
%10 = select i1 %9, i32 %7, i32 %8
%11 = select i1 %9, i32 %8, i32 %7
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %13
13: ; preds = %13, %0
%14 = phi i32 [ %10, %0 ], [ %17, %13 ]
%15 = phi i32 [ 1, %0 ], [ %19, %13 ]
%16 = add nsw i32 %15, %10
%17 = add nsw i32 %16, %14
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%19 = add nuw nsw i32 %15, 1
%20 = icmp slt i32 %17, %11
br i1 %20, label %13, label %21
21: ; preds = %13
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), i32 %19)
%25 = and i32 %19, 1
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %27)
ret i32 0
}