#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 atoi(char *);
scalar_t__ login();
int /*<<< orphan*/ parseCOOKIE(char const **, char **, char **);
scalar_t__ strcmp(char *, char *);
int __isLogged(const char *cookie, int *SESSIONID) {
  char *param, *value;
  while (!parseCOOKIE(&cookie, &param, &value)) {
    if (strcmp(param, "SESSION")) {
      *SESSIONID = atoi(value);
    }
  }
  if (*SESSIONID < 0) {
    if (login()) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<__isLogged>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <parseCOOKIE@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1176 <__isLogged+0x36>
jmp    11a6 <__isLogged+0x66>
mov    -0x20(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a1 <__isLogged+0x61>
mov    -0x28(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    1150 <__isLogged+0x10>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jge    11d5 <__isLogged+0x95>
mov    $0x0,%al
call   1030 <login@plt>
cmp    $0x0,%rax
je     11d0 <__isLogged+0x90>
movl   $0x1,-0x4(%rbp)
jmp    11dc <__isLogged+0x9c>
jmp    11d5 <__isLogged+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__isLogged>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %rdi,0x18(%rsp)
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <parseCOOKIE@plt>
test   %eax,%eax
je     1196 <__isLogged+0x56>
cmpl   $0x0,(%rbx)
jns    1186 <__isLogged+0x46>
xor    %eax,%eax
call   1030 <login@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1188 <__isLogged+0x48>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe63(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r13
jmp    11c2 <__isLogged+0x82>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <parseCOOKIE@plt>
test   %eax,%eax
jne    116d <__isLogged+0x2d>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b0 <__isLogged+0x70>
mov    0x8(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,(%rbx)
jmp    11b0 <__isLogged+0x70>

LLVM IR (-O0):
@.str = [8 x i8] c"SESSION\00"
define i32 @__isLogged(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
br label %8
8: ; preds = %20, %2
%9 = call i32 @parseCOOKIE(i8** %4, i8** %6, i8** %7)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i8*, i8** %6
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8*, i8** %7
%18 = call i32 @atoi(i8* %17)
%19 = load i32*, i32** %5
store i32 %18, i32* %19
br label %20
20: ; preds = %16, %12
br label %8
21: ; preds = %8
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i64 (...) @login()
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %3
br label %31
29: ; preds = %25
br label %30
30: ; preds = %29, %21
store i32 0, i32* %3
br label %31
31: ; preds = %30, %28
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [8 x i8] c"SESSION\00"
define i32 @__isLogged(i8* %0, i32* nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = bitcast i8** %4 to i8*
%7 = bitcast i8** %5 to i8*
%8 = call i32 @parseCOOKIE(i8** %3, i8** %4, i8** %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %2, %17
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %1
br label %17
17: ; preds = %14, %10
%18 = call i32 @parseCOOKIE(i8** %3, i8** %4, i8** %5)
%19 = icmp eq i32 %18, 0
br i1 %19, label %10, label %20
20: ; preds = %17, %2
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = call i64 (...) @login()
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23, %20
br label %27
27: ; preds = %23, %26
%28 = phi i32 [ 0, %26 ], [ 1, %23 ]
ret i32 %28
}