#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 */
struct cuser_ctx {
  int dummy;
};

/* Variables and functions */
int cuser_check_user(struct cuser_ctx *, char *, char *);
int /*<<< orphan*/ cuser_fini(struct cuser_ctx *);
struct cuser_ctx *cuser_init(char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  struct cuser_ctx *ctx;
  int ret;
  if (argc < 3)
    return -1;
  ctx = cuser_init("127.0.0.1");
  ret = cuser_check_user(ctx, argv[1], argv[2]);
  if (ret < 0) {
    printf("err code is %d\n", ret);
    return 0;
  }
  printf("%d\n", ret);
  cuser_fini(ctx);
  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)
cmpl   $0x3,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dc <main+0x9c>
lea    0xe8d(%rip),%rdi
call   1040 <cuser_init@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
call   1060 <cuser_check_user@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11bd <main+0x7d>
mov    -0x1c(%rbp),%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11dc <main+0x9c>
mov    -0x1c(%rbp),%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <cuser_fini@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%eax
cmp    $0x3,%edi
jl     119c <main+0x5c>
mov    %rsi,%rbx
lea    0xea8(%rip),%rdi
call   1040 <cuser_init@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
mov    %rax,%rdi
call   1060 <cuser_check_user@plt>
test   %eax,%eax
js     118c <main+0x4c>
lea    0xe9b(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1050 <cuser_fini@plt>
jmp    119a <main+0x5a>
lea    0xe77(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.cuser_ctx = type { i32 }
@.str = [10 x i8] c"127.0.0.1\00"
@.str.1 = [16 x i8] c"err code is %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = tail call %struct.cuser_ctx* @cuser_init(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @cuser_check_user(%struct.cuser_ctx* %5, i8* %7, i8* %9)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %17
14: ; preds = %4
%15 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%16 = tail call i32 @cuser_fini(%struct.cuser_ctx* %5)
br label %17
17: ; preds = %2, %14, %12
%18 = phi i32 [ 0, %12 ], [ 0, %14 ], [ -1, %2 ]
ret i32 %18
}