#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);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  int a, b, sum = 0;
  while (1) {
    scanf("%d %d", &a, &b);
    if (!(a || b)) {
      break;
    }
    sum += (--a) ? -b : b;
  }
  if (sum < 0) {
    printf("Bad\n%d", -sum);
  } else {
    printf("Good\n%d", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1163 <main+0x43>
cmpl   $0x0,-0xc(%rbp)
jne    1163 <main+0x43>
jmp    1196 <main+0x76>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1182 <main+0x62>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <main+0x68>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <main+0x16>
cmpl   $0x0,-0x10(%rbp)
jge    11b6 <main+0x96>
xor    %esi,%esi
sub    -0x10(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
jmp    11c5 <main+0xa5>
mov    -0x10(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
call   1040 <scanf@plt>
mov    (%rsp),%ecx
mov    0x4(%rsp),%eax
xor    %ebx,%ebx
mov    %ecx,%edx
or     %eax,%edx
je     118e <main+0x6e>
xor    %ebx,%ebx
lea    0xeac(%rip),%r14
mov    %rsp,%r15
lea    0x4(%rsp),%r12
nopl   0x0(%rax)
mov    %eax,%edx
neg    %edx
add    $0xffffffff,%ecx
mov    %ecx,(%rsp)
cmove  %eax,%edx
add    %edx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <scanf@plt>
mov    (%rsp),%ecx
mov    0x4(%rsp),%eax
mov    %ecx,%edx
or     %eax,%edx
jne    1160 <main+0x40>
test   %ebx,%ebx
js     1197 <main+0x77>
lea    0xe78(%rip),%rdi
jmp    11a0 <main+0x80>
neg    %ebx
lea    0xe66(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [7 x i8] c"Bad\0A%d\00"
@.str.2 = [8 x i8] c"Good\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %0, %22
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %9
br label %26
13: ; preds = %9, %5
%14 = load i32, i32* %2
%15 = add nsw i32 %14, -1
store i32 %15, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sub nsw i32 0, %18
br label %22
20: ; preds = %13
%21 = load i32, i32* %3
br label %22
22: ; preds = %20, %17
%23 = phi i32 [ %19, %17 ], [ %21, %20 ]
%24 = load i32, i32* %4
%25 = add nsw i32 %24, %23
store i32 %25, i32* %4
br label %5
26: ; preds = %12
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i32, i32* %4
%31 = sub nsw i32 0, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %36
33: ; preds = %26
%34 = load i32, i32* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %29
ret i32 0
}

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