#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*/ fprintf(int /*<<< orphan*/, char *, char *);
char *iwas4g_get_error();
int /*<<< orphan*/ iwas4g_reauth();
int iwas4g_watch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int reauth(void) {
  int rtnval;
  printf("Perform re-authentication.\n");
  while ((rtnval = iwas4g_watch()) != -1) {
    switch (rtnval) {
    case 1:
      printf("%s\n", iwas4g_get_error());
      if (iwas4g_reauth()) {
        fprintf(stderr, "Re-authentication fails: %s\n", iwas4g_get_error());
        return (-1);
      } else {
        fprintf(stdout, "%s\n", iwas4g_get_error());
      }
      break;
    case 2:
      fprintf(stderr, "Re-authentication fails: %s\n", iwas4g_get_error());
      return (-1);
      break;
    }
  }
  fprintf(stderr, "Re-authentication fails: %s\n", iwas4g_get_error());
  return (-1);
}


x86 assembly (clang, -O0):
<reauth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <iwas4g_watch@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
je     1257 <reauth+0x107>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     119e <reauth+0x4e>
jmp    118d <reauth+0x3d>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1221 <reauth+0xd1>
jmp    1252 <reauth+0x102>
mov    $0x0,%al
call   1030 <iwas4g_get_error@plt>
mov    %rax,%rsi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <iwas4g_reauth@plt>
cmp    $0x0,%eax
je     11f7 <reauth+0xa7>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <iwas4g_get_error@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe36(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1283 <reauth+0x133>
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <iwas4g_get_error@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe1e(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1252 <reauth+0x102>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <iwas4g_get_error@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xddb(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1283 <reauth+0x133>
jmp    1166 <reauth+0x16>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <iwas4g_get_error@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xda5(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reauth>:
push   %rbp
push   %r14
push   %rbx
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e71(%rip),%r14
lea    0xeab(%rip),%rbx
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <iwas4g_watch@plt>
cmp    $0x1,%eax
je     1190 <reauth+0x40>
cmp    $0xffffffff,%eax
je     11c3 <reauth+0x73>
cmp    $0x2,%eax
jne    1170 <reauth+0x20>
jmp    11c3 <reauth+0x73>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <iwas4g_get_error@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <iwas4g_reauth@plt>
test   %eax,%eax
jne    11c3 <reauth+0x73>
mov    (%r14),%ebp
xor    %eax,%eax
call   1040 <iwas4g_get_error@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
jmp    1170 <reauth+0x20>
mov    0x2e16(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <iwas4g_get_error@plt>
lea    0xe26(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Perform re-authentication.\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"Re-authentication fails: %s\0A\00"
@stdout = global i32 0
define i32 @reauth() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %27, %0
%5 = call i32 (...) @iwas4g_watch()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, -1
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = load i32, i32* %2
switch i32 %8, label %27 [
i32 1, label %9
i32 2, label %23
]
9: ; preds = %7
%10 = call i8* (...) @iwas4g_get_error()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (...) @iwas4g_reauth()
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = call i8* (...) @iwas4g_get_error()
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %16)
store i32 -1, i32* %1
br label %32
18: ; preds = %9
%19 = load i32, i32* @stdout
%20 = call i8* (...) @iwas4g_get_error()
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18
br label %27
23: ; preds = %7
%24 = load i32, i32* @stderr
%25 = call i8* (...) @iwas4g_get_error()
%26 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 -1, i32* %1
br label %32
27: ; preds = %7, %22
br label %4
28: ; preds = %4
%29 = load i32, i32* @stderr
%30 = call i8* (...) @iwas4g_get_error()
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %30)
store i32 -1, i32* %1
br label %32
32: ; preds = %28, %23, %14
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"Re-authentication fails: %s\0A\00"
@stdout = global i32 0
@str = [27 x i8] c"Perform re-authentication.\00"
define i32 @reauth() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %4, %0
%3 = tail call i32 (...) @iwas4g_watch()
switch i32 %3, label %4 [
i32 -1, label %14
i32 1, label %5
i32 2, label %14
]
4: ; preds = %2, %10
br label %2
5: ; preds = %2
%6 = tail call i8* (...) @iwas4g_get_error()
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
%8 = tail call i32 (...) @iwas4g_reauth()
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = load i32, i32* @stdout
%12 = tail call i8* (...) @iwas4g_get_error()
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %4
14: ; preds = %2, %2, %5
%15 = load i32, i32* @stderr
%16 = tail call i8* (...) @iwas4g_get_error()
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 -1
}