#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 scanf(char *, int *, int *);
int main(void) {
  int x, y;
  while (scanf("%d %d\n", &x, &y), x != 0 && y != 0) {
    if (x < 0) {
      if (y < 0) {
        printf("terceiro\n");
      } else {
        printf("segundo\n");
      }
    } else {
      if (y < 0) {
        printf("quarto\n");
      } else {
        printf("primeiro\n");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0xd(%rbp)
je     115c <main+0x3c>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    116c <main+0x4c>
jmp    11d3 <main+0xb3>
cmpl   $0x0,-0x8(%rbp)
jge    11a2 <main+0x82>
cmpl   $0x0,-0xc(%rbp)
jge    1191 <main+0x71>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    119d <main+0x7d>
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <main+0xae>
cmpl   $0x0,-0xc(%rbp)
jge    11bd <main+0x9d>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <main+0xae>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11bf <main+0x9f>
mov    (%rsp),%ecx
test   %ecx,%ecx
je     11bf <main+0x9f>
lea    0xec2(%rip),%r13
lea    0xeb4(%rip),%rbp
lea    0xea4(%rip),%r12
lea    0xe96(%rip),%r14
lea    0x4(%rsp),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ecx,%ecx
mov    %r13,%rcx
lea    0xe93(%rip),%rdx
cmovs  %rdx,%rcx
mov    %r12,%rdi
cmovs  %rbp,%rdi
test   %eax,%eax
cmovs  %rcx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11bf <main+0x9f>
mov    (%rsp),%ecx
test   %ecx,%ecx
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
@str = [9 x i8] c"primeiro\00"
@str.5 = [7 x i8] c"quarto\00"
@str.6 = [8 x i8] c"segundo\00"
@str.7 = [9 x i8] c"terceiro\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 ([7 x i8], [7 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 %9, i1 false
br i1 %10, label %11, label %26
11: ; preds = %0, %11
%12 = phi i32 [ %23, %11 ], [ %8, %0 ]
%13 = phi i32 [ %21, %11 ], [ %6, %0 ]
%14 = icmp slt i32 %13, 0
%15 = icmp slt i32 %12, 0
%16 = select i1 %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.6, i64 0, i64 0)
%17 = select i1 %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0)
%18 = select i1 %14, i8* %16, i8* %17
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 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 %24, i1 false
br i1 %25, label %11, label %26
26: ; preds = %11, %0
ret i32 0
}