#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 */
typedef struct db_t TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ db;
struct db_t {
  char *login;
  char *passwd;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(TYPE_1__ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strcpy(char *, char *);
int adduser(char *login, char *passwd) {
  struct db_t {
    char login[255];
    char passwd[255];
  } db;
  FILE *arq;
  strcpy(db.login, login);
  strcpy(db.passwd, passwd);
  arq = fopen("db_ip", "a+b");
  if (arq == NULL)
    exit(1);
  fwrite(&db, sizeof(db), 1, arq);
  fclose(arq);
}


x86 assembly (clang, -O0):
<adduser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x218(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x218(%rbp),%rdi
add    $0xff,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xe6f(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x220(%rbp)
cmpq   $0x0,-0x220(%rbp)
jne    11bc <adduser+0x6c>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    -0x218(%rbp),%rdi
mov    -0x220(%rbp),%rcx
mov    $0x1fe,%esi
mov    $0x1,%edx
call   1070 <fwrite@plt>
mov    -0x220(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adduser>:
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xff(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe83(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11b7 <adduser+0x67>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1fe,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x200,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.db_t = type { [255 x i8], [255 x i8] }
%struct.db_t.0 = type { i8*, i8* }
@.str = [6 x i8] c"db_ip\00"
@.str.1 = [4 x i8] c"a+b\00"
define i32 @adduser(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.db_t
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds %struct.db_t, %struct.db_t* %6, i32 0, i32 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds %struct.db_t, %struct.db_t* %6, i32 0, i32 1
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %12, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = bitcast %struct.db_t* %6 to %struct.db_t.0*
%23 = load i32*, i32** %7
%24 = call i32 @fwrite(%struct.db_t.0* %22, i32 510, i32 1, i32* %23)
%25 = load i32*, i32** %7
%26 = call i32 @fclose(i32* %25)
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
%struct.db_t = type { [255 x i8], [255 x i8] }
%struct.db_t.0 = type { i8*, i8* }
@.str = [6 x i8] c"db_ip\00"
@.str.1 = [4 x i8] c"a+b\00"
define i32 @adduser(i8* %0, i8* %1) {
%3 = alloca %struct.db_t
%4 = getelementptr inbounds %struct.db_t, %struct.db_t* %3, i64 0, i32 0, i64 0
%5 = call i32 @strcpy(i8* %4, i8* %0)
%6 = getelementptr inbounds %struct.db_t, %struct.db_t* %3, i64 0, i32 1, i64 0
%7 = call i32 @strcpy(i8* %6, i8* %1)
%8 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = bitcast %struct.db_t* %3 to %struct.db_t.0*
%14 = call i32 @fwrite(%struct.db_t.0* %13, i32 510, i32 1, i32* %8)
%15 = call i32 @fclose(i32* %8)
ret i32 undef
}