#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int pass_read(char *user, char *pwd, FILE *fp) {
  char buf[4096], *p;
  if ((fgets(buf, 4096, fp)) == NULL)
    return -1;
  if ((p = strchr(buf, ':')) == NULL)
    return -1;
  *p++ = 0;
  strcpy(user, buf);
  strcpy(pwd, p);
  if ((p = strchr(pwd, '\n')) != NULL)
    *p = 0;
  return 0;
}


x86 assembly (clang, -O0):
<pass_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x1000,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1172 <pass_read+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <pass_read+0xd8>
lea    -0x1020(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x1028(%rbp)
cmp    $0x0,%rax
jne    11a0 <pass_read+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <pass_read+0xd8>
mov    -0x1028(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x1028(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1028(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x1028(%rbp)
cmp    $0x0,%rax
je     1201 <pass_read+0xd1>
mov    -0x1028(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pass_read>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%rdi
mov    $0x1000,%esi
call   1050 <fgets@plt>
mov    $0xffffffff,%ebp
test   %rax,%rax
je     11a1 <pass_read+0x71>
mov    %rsp,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11a1 <pass_read+0x71>
mov    %rax,%rbp
add    $0x1,%rbp
movb   $0x0,(%rax)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a1 <pass_read+0x71>
movb   $0x0,(%rax)
mov    %ebp,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pass_read(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [4096 x i8]
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%11 = load i32*, i32** %7
%12 = call i32* @fgets(i8* %10, i32 4096, i32* %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 -1, i32* %4
br label %35
15: ; preds = %3
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%17 = call i8* @strchr(i8* %16, i8 signext 58)
store i8* %17, i8** %9
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 -1, i32* %4
br label %35
20: ; preds = %15
%21 = load i8*, i8** %9
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %9
store i8 0, i8* %21
%23 = load i8*, i8** %5
%24 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %6
%27 = load i8*, i8** %9
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load i8*, i8** %6
%30 = call i8* @strchr(i8* %29, i8 signext 10)
store i8* %30, i8** %9
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %34
32: ; preds = %20
%33 = load i8*, i8** %9
store i8 0, i8* %33
br label %34
34: ; preds = %32, %20
store i32 0, i32* %4
br label %35
35: ; preds = %34, %19, %14
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @pass_read(i8* %0, i8* %1, i32* nocapture %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = call i32* @fgets(i8* %5, i32 4096, i32* %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %18, label %8
8: ; preds = %3
%9 = call i8* @strchr(i8* %5, i8 signext 58)
%10 = icmp eq i8* %9, null
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
store i8 0, i8* %9
%13 = call i32 @strcpy(i8* %0, i8* %5)
%14 = call i32 @strcpy(i8* %1, i8* %12)
%15 = call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 10)
%16 = icmp eq i8* %15, null
br i1 %16, label %18, label %17
17: ; preds = %11
store i8 0, i8* %15
br label %18
18: ; preds = %11, %17, %8, %3
%19 = phi i32 [ -1, %3 ], [ -1, %8 ], [ 0, %17 ], [ 0, %11 ]
ret i32 %19
}