#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*/ time_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ assert(int);
int fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int registerSuccess(char *arg0) {
  char *newname;
  int namelen, extlen, ret;
  FILE *fpass;
  time_t timenow;
  char strnow[20];
  namelen = strlen(arg0);
  extlen = strlen(".pass");
  newname = malloc(namelen + extlen + 1);
  if (newname == NULL) {
    perror("register_success");
    return EXIT_FAILURE;
  }
  memcpy(newname, arg0, namelen);
  memcpy(newname + namelen, ".pass", extlen);
  newname[namelen + extlen] = '\0';
  fpass = fopen(newname, "w");
  free(newname);
  if (fpass == NULL) {
    perror("register_success");
    return EXIT_FAILURE;
  }
  timenow = time(NULL);
  strftime(strnow, 20, "%Y-%m-%d %H:%M:%S", localtime(&timenow));
  fwrite(strnow, sizeof(char), 19, fpass);
  ret = fclose(fpass);
  assert(ret == 0);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<registerSuccess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
lea    0xe21(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1221 <registerSuccess+0x61>
lea    0xdfb(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1315 <registerSuccess+0x155>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <memcpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%edx
lea    0xdba(%rip),%rsi
call   1080 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xdb0(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12a1 <registerSuccess+0xe1>
lea    0xd7b(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1315 <registerSuccess+0x155>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x34(%rbp),%rdi
call   1040 <localtime@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xd49(%rip),%rdx
call   10b0 <strftime@plt>
lea    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
mov    $0x13,%edx
call   10e0 <fwrite@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2cc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<registerSuccess>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%r14
call   1060 <strlen@plt>
mov    %eax,%r12d
lea    0xe22(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
lea    (%r15,%r12,1),%edi
add    $0x1,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12bd <registerSuccess+0xfd>
mov    %rax,%rbx
mov    %r15d,%ebp
add    %r12d,%ebp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1080 <memcpy@plt>
movslq %r12d,%rdi
add    %rbx,%rdi
lea    0xde1(%rip),%rsi
mov    %r15d,%edx
call   1080 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
lea    0xde2(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     12bd <registerSuccess+0xfd>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xdb0(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%ecx
call   10b0 <strftime@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x13,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd42(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d10(%rip),%rax
jmp    12ae <registerSuccess+0xee>

LLVM IR (-O0):
@.str = [6 x i8] c".pass\00"
@.str.1 = [17 x i8] c"register_success\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@EXIT_SUCCESS = global i32 0
define i32 @registerSuccess(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [20 x i8]
store i8* %0, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %5
%13 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = add nsw i32 %14, %15
%17 = add nsw i32 %16, 1
%18 = call i8* @malloc(i32 %17)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %1
%22 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %2
br label %65
24: ; preds = %1
%25 = load i8*, i8** %4
%26 = load i8*, i8** %3
%27 = load i32, i32* %5
%28 = call i32 @memcpy(i8* %25, i8* %26, i32 %27)
%29 = load i8*, i8** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i32, i32* %6
%34 = call i32 @memcpy(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i8*, i8** %4
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %35, i64 %39
store i8 0, i8* %40
%41 = load i8*, i8** %4
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %42, i32** %8
%43 = load i8*, i8** %4
%44 = call i32 @free(i8* %43)
%45 = load i32*, i32** %8
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %50
47: ; preds = %24
%48 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %2
br label %65
50: ; preds = %24
%51 = call i32 @time(i32* null)
store i32 %51, i32* %9
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%53 = call i32 @localtime(i32* %9)
%54 = call i32 @strftime(i8* %52, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%56 = load i32*, i32** %8
%57 = call i32 @fwrite(i8* %55, i32 1, i32 19, i32* %56)
%58 = load i32*, i32** %8
%59 = call i32 @fclose(i32* %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = icmp eq i32 %60, 0
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = load i32, i32* @EXIT_SUCCESS
store i32 %64, i32* %2
br label %65
65: ; preds = %50, %47, %21
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
@.str = [6 x i8] c".pass\00"
@.str.1 = [17 x i8] c"register_success\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@EXIT_SUCCESS = global i32 0
define i32 @registerSuccess(i8* %0) {
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = add nsw i32 %7, %6
%9 = add nsw i32 %8, 1
%10 = tail call i8* @malloc(i32 %9)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %1
%13 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %35
14: ; preds = %1
%15 = tail call i32 @memcpy(i8* %10, i8* %0, i32 %6)
%16 = sext i32 %6 to i64
%17 = getelementptr inbounds i8, i8* %10, i64 %16
%18 = tail call i32 @memcpy(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
%19 = sext i32 %8 to i64
%20 = getelementptr inbounds i8, i8* %10, i64 %19
store i8 0, i8* %20
%21 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @free(i8* %10)
%23 = icmp eq i32* %21, null
br i1 %23, label %24, label %26
24: ; preds = %14
%25 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %35
26: ; preds = %14
%27 = tail call i32 @time(i32* null)
store i32 %27, i32* %2
%28 = call i32 @localtime(i32* %2)
%29 = call i32 @strftime(i8* %5, i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = call i32 @fwrite(i8* %5, i32 1, i32 19, i32* %21)
%31 = call i32 @fclose(i32* %21)
%32 = icmp eq i32 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
br label %35
35: ; preds = %26, %24, %12
%36 = phi i32* [ @EXIT_FAILURE, %12 ], [ @EXIT_FAILURE, %24 ], [ @EXIT_SUCCESS, %26 ]
%37 = load i32, i32* %36
ret i32 %37
}