#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 */
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int /*<<< orphan*/ _IONBF;
int do_stuff();
int /*<<< orphan*/ getegid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setresgid(int /*<<< orphan*/, int /*<<< orphan*/,
                             int /*<<< orphan*/);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ win();
int main(int argc, char **argv) {
  setvbuf(stdout, NULL, _IONBF, 0);
  gid_t gid = getegid();
  setresgid(gid, gid, gid);
  int res;
  printf("Welcome to my guessing game!\n\n");
  while (1) {
    res = do_stuff();
    if (res) {
      win();
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
mov    $0x0,%al
call   1060 <getegid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <setresgid@plt>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <do_stuff@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11d2 <main+0x72>
mov    $0x0,%al
call   1050 <win@plt>
jmp    11b7 <main+0x57>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
xor    %eax,%eax
call   1060 <getegid@plt>
mov    %eax,%edi
mov    %eax,%esi
mov    %eax,%edx
call   1040 <setresgid@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <do_stuff@plt>
test   %eax,%eax
je     11a0 <main+0x40>
xor    %eax,%eax
call   1050 <win@plt>
jmp    11a0 <main+0x40>

LLVM IR (-O0):
@stdout = global i32 0
@_IONBF = global i32 0
@.str = [31 x i8] c"Welcome to my guessing game!\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @stdout
%9 = load i32, i32* @_IONBF
%10 = call i32 @setvbuf(i32 %8, i32* null, i32 %9, i32 0)
%11 = call i32 (...) @getegid()
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @setresgid(i32 %12, i32 %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %2, %23
%18 = call i32 (...) @do_stuff()
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @win()
br label %23
23: ; preds = %21, %17
br label %17
}

LLVM IR (-O2):
@stdout = global i32 0
@_IONBF = global i32 0
@str = [30 x i8] c"Welcome to my guessing game!\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = load i32, i32* @_IONBF
%5 = tail call i32 @setvbuf(i32 %3, i32* null, i32 %4, i32 0)
%6 = tail call i32 (...) @getegid()
%7 = tail call i32 @setresgid(i32 %6, i32 %6, i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %14, %2
%10 = tail call i32 (...) @do_stuff()
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (...) @win()
br label %14
14: ; preds = %12, %9
br label %9
}