#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ free_list();
scalar_t__ insert_users(char *, char *, char *, char *, char *);
char *malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strip_char_from_end(char, char *);
int strlen(char *);
char *strtok(char *, char *);
int read_user_data() {
  FILE *fp_users;
  char *data;
  char *servernick;
  char *serverip;
  char *statustemp;
  char *channels;
  char *password;
  if (free_list() < 0) {
    return (-1);
  }
  if ((data = malloc(1000)) == NULL) {
    fprintf(stderr, "read_user_data: Malloc Error!\n");
    return (-1);
  }
  if ((fp_users = fopen("/jffs/etc/acidblood.users", "r")) == NULL) {
    return (-1);
  }
  while ((fgets(data, 1000, fp_users)) != NULL) {
    if (*data != '#' && (strlen(data) > 1)) {
      servernick = strtok(data, ":");
      serverip = strtok(NULL, ":");
      statustemp = strtok(NULL, ":");
      channels = strtok(NULL, ":");
      password = strtok(NULL, "\n");
      strip_char_from_end('\n', channels);
      if ((insert_users(servernick, serverip, statustemp, channels, password)) <
          0) {
        return (-1);
      }
    }
  }
  fclose(fp_users);
  return (0);
}


x86 assembly (clang, -O0):
<read_user_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1070 <free_list@plt>
cmp    $0x0,%rax
jge    11c5 <read_user_data+0x25>
movl   $0xffffffff,-0x4(%rbp)
jmp    1329 <read_user_data+0x189>
mov    $0x3e8,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fe <read_user_data+0x5e>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1329 <read_user_data+0x189>
lea    0xe1a(%rip),%rdi
lea    0xe2d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    122b <read_user_data+0x8b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1329 <read_user_data+0x189>
jmp    1230 <read_user_data+0x90>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1319 <read_user_data+0x179>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1314 <read_user_data+0x174>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x1,%eax
jle    1314 <read_user_data+0x174>
mov    -0x18(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdae(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9a(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd86(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd54(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rsi
mov    $0xa,%edi
call   10a0 <strip_char_from_end@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   1050 <insert_users@plt>
cmp    $0x0,%rax
jge    130f <read_user_data+0x16f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1329 <read_user_data+0x189>
jmp    1314 <read_user_data+0x174>
jmp    1230 <read_user_data+0x90>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_user_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1070 <free_list@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
js     12d2 <read_user_data+0x132>
mov    $0x3e8,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     12b1 <read_user_data+0x111>
mov    %rax,%rbx
lea    0xe3f(%rip),%rdi
lea    0xe52(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12aa <read_user_data+0x10a>
mov    %rax,%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12c8 <read_user_data+0x128>
cmpb   $0x23,(%rbx)
je     1200 <read_user_data+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jl     1200 <read_user_data+0x60>
mov    %rbx,%rdi
lea    0xe06(%rip),%rbp
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,0x10(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,0x8(%rsp)
xor    %edi,%edi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %rbp,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r15
xor    %edi,%edi
lea    0xda9(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,%r13
mov    $0xa,%edi
mov    %r15,%rsi
call   10a0 <strip_char_from_end@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r13,%r8
call   1050 <insert_users@plt>
test   %rax,%rax
jns    1200 <read_user_data+0x60>
mov    $0xffffffff,%ebp
jmp    12d2 <read_user_data+0x132>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12d2 <read_user_data+0x132>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"read_user_data: Malloc Error!\0A\00"
@.str.1 = [26 x i8] c"/jffs/etc/acidblood.users\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c":\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @read_user_data() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = call i64 (...) @free_list()
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 -1, i32* %1
br label %59
12: ; preds = %0
%13 = call i8* @malloc(i32 1000)
store i8* %13, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %59
18: ; preds = %12
%19 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %2
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 -1, i32* %1
br label %59
22: ; preds = %18
br label %23
23: ; preds = %55, %22
%24 = load i8*, i8** %3
%25 = load i32*, i32** %2
%26 = call i32* @fgets(i8* %24, i32 1000, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %56
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 35
br i1 %32, label %33, label %55
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @strlen(i8* %34)
%36 = icmp sgt i32 %35, 1
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = call i8* @strtok(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %39, i8** %4
%40 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %40, i8** %5
%41 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %41, i8** %6
%42 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %42, i8** %7
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %43, i8** %8
%44 = load i8*, i8** %7
%45 = call i32 @strip_char_from_end(i8 signext 10, i8* %44)
%46 = load i8*, i8** %4
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = load i8*, i8** %7
%50 = load i8*, i8** %8
%51 = call i64 @insert_users(i8* %46, i8* %47, i8* %48, i8* %49, i8* %50)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %37
store i32 -1, i32* %1
br label %59
54: ; preds = %37
br label %55
55: ; preds = %54, %33, %28
br label %23
56: ; preds = %23
%57 = load i32*, i32** %2
%58 = call i32 @fclose(i32* %57)
store i32 0, i32* %1
br label %59
59: ; preds = %56, %53, %21, %15, %11
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"read_user_data: Malloc Error!\0A\00"
@.str.1 = [26 x i8] c"/jffs/etc/acidblood.users\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c":\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @read_user_data() {
%1 = tail call i64 (...) @free_list()
%2 = icmp slt i64 %1, 0
br i1 %2, label %35, label %3
3: ; preds = %0
%4 = tail call dereferenceable_or_null(1000) i8* @malloc(i32 1000)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %35
9: ; preds = %3
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %35, label %12
12: ; preds = %9
%13 = tail call i32* @fgets(i8* %4, i32 1000, i32* %10)
%14 = icmp eq i32* %13, null
br i1 %14, label %33, label %15
15: ; preds = %12, %30
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 35
br i1 %17, label %30, label %18
18: ; preds = %15
%19 = tail call i32 @strlen(i8* %4)
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = tail call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @strip_char_from_end(i8 signext 10, i8* %25)
%28 = tail call i64 @insert_users(i8* %22, i8* %23, i8* %24, i8* %25, i8* %26)
%29 = icmp slt i64 %28, 0
br i1 %29, label %35, label %30
30: ; preds = %21, %18, %15
%31 = tail call i32* @fgets(i8* %4, i32 1000, i32* %10)
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %15
33: ; preds = %30, %12
%34 = tail call i32 @fclose(i32* %10)
br label %35
35: ; preds = %21, %9, %0, %33, %6
%36 = phi i32 [ -1, %6 ], [ 0, %33 ], [ -1, %0 ], [ -1, %9 ], [ -1, %21 ]
ret i32 %36
}