#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 user_get_id(int, char *);
int /*<<< orphan*/ user_join(int, int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ user_set_seen(int, char *);
int user_status(int cid, int add, char *nick, char *user, char *host) {
  int id;
  id = user_get_id(cid, nick);
  if (id == 0 && add) {
    user_join(cid, NULL, nick, user, host);
    id = user_get_id(cid, nick);
  }
  if (id != 0)
    user_set_seen(cid, nick);
  return id;
}


x86 assembly (clang, -O0):
<user_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <user_get_id@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1194 <user_status+0x64>
cmpl   $0x0,-0x8(%rbp)
je     1194 <user_status+0x64>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
xor    %eax,%eax
mov    %eax,%esi
call   1030 <user_join@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <user_get_id@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11aa <user_status+0x7a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <user_set_seen@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<user_status>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r15
mov    %esi,%ebp
mov    %edi,%r13d
mov    %rdx,%rsi
call   1050 <user_get_id@plt>
mov    %eax,%ebx
test   %ebp,%ebp
je     117b <user_status+0x4b>
test   %ebx,%ebx
jne    117b <user_status+0x4b>
mov    %r13d,%edi
xor    %esi,%esi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1030 <user_join@plt>
mov    %r13d,%edi
mov    %r15,%rsi
call   1050 <user_get_id@plt>
mov    %eax,%ebx
test   %ebx,%ebx
je     118a <user_status+0x5a>
mov    %r13d,%edi
mov    %r15,%rsi
call   1040 <user_set_seen@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @user_status(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i32, i32* %6
%13 = load i8*, i8** %8
%14 = call i32 @user_get_id(i32 %12, i8* %13)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %29
17: ; preds = %5
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %6
%22 = load i8*, i8** %8
%23 = load i8*, i8** %9
%24 = load i8*, i8** %10
%25 = call i32 @user_join(i32 %21, i32* null, i8* %22, i8* %23, i8* %24)
%26 = load i32, i32* %6
%27 = load i8*, i8** %8
%28 = call i32 @user_get_id(i32 %26, i8* %27)
store i32 %28, i32* %11
br label %29
29: ; preds = %20, %17, %5
%30 = load i32, i32* %11
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* %6
%34 = load i8*, i8** %8
%35 = call i32 @user_set_seen(i32 %33, i8* %34)
br label %36
36: ; preds = %32, %29
%37 = load i32, i32* %11
ret i32 %37
}

LLVM IR (-O2):
define i32 @user_status(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 @user_get_id(i32 %0, i8* %2)
%7 = icmp eq i32 %6, 0
%8 = icmp ne i32 %1, 0
%9 = and i1 %8, %7
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i32 @user_join(i32 %0, i32* null, i8* %2, i8* %3, i8* %4)
%12 = tail call i32 @user_get_id(i32 %0, i8* %2)
br label %13
13: ; preds = %10, %5
%14 = phi i32 [ %12, %10 ], [ %6, %5 ]
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @user_set_seen(i32 %0, i8* %2)
br label %18
18: ; preds = %16, %13
ret i32 %14
}