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

/* Variables and functions */
char *malloc(int);
int sscanf(char *, char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int read_login_data(char *data, char **username, char **password) {
  int c;
  char u[32];
  char p[32];
  char cl[32];
  *username = malloc(32);
  *password = malloc(32);
  c = sscanf(data, "%[^=]=%[^&]&%[^=]=%[^&]&%s", u, *username, p, *password,
             cl);
  return c == 5 && !strncmp(u, "username", 32) && !strncmp(p, "password", 32) &&
         !strncmp(cl, "commit=Login", 32);
}


x86 assembly (clang, -O0):
<read_login_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    -0x60(%rbp),%r8
mov    -0x18(%rbp),%rax
mov    (%rax),%r9
lea    -0x80(%rbp),%rax
lea    0xe6c(%rip),%rsi
mov    %rax,(%rsp)
call   1050 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x5,-0x1c(%rbp)
mov    %al,-0x81(%rbp)
jne    1225 <read_login_data+0xf5>
lea    -0x40(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x81(%rbp)
jne    1225 <read_login_data+0xf5>
lea    -0x60(%rbp),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x81(%rbp)
jne    1225 <read_login_data+0xf5>
lea    -0x80(%rbp),%rdi
lea    0xe20(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_login_data>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    (%rbx),%rcx
lea    0x10(%rsp),%rdx
mov    %rdx,(%rsp)
lea    0xe91(%rip),%rsi
lea    0x50(%rsp),%rdx
lea    0x30(%rsp),%r8
mov    %r15,%rdi
mov    %rax,%r9
call   1050 <sscanf@plt>
xor    %ebx,%ebx
cmp    $0x5,%eax
jne    11dc <read_login_data+0xac>
lea    0xe89(%rip),%rsi
lea    0x50(%rsp),%rdi
mov    $0x20,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11dc <read_login_data+0xac>
lea    0xe78(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    $0x20,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11dc <read_login_data+0xac>
lea    0xe67(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0x20,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%[^=]=%[^&]&%[^=]=%[^&]&%s\00"
@.str.1 = [9 x i8] c"username\00"
@.str.2 = [9 x i8] c"password\00"
@.str.3 = [13 x i8] c"commit=Login\00"
define i32 @read_login_data(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = alloca [32 x i8]
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%11 = call i8* @malloc(i32 32)
%12 = load i8**, i8*** %5
store i8* %11, i8** %12
%13 = call i8* @malloc(i32 32)
%14 = load i8**, i8*** %6
store i8* %13, i8** %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%20 = load i8**, i8*** %6
%21 = load i8*, i8** %20
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%23 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %18, i8* %19, i8* %21, i8* %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 5
br i1 %25, label %26, label %39
26: ; preds = %3
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%28 = call i32 @strncmp(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 32)
%29 = icmp ne i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %26
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 32)
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %30
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%36 = call i32 @strncmp(i8* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 32)
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
br label %39
39: ; preds = %34, %30, %26, %3
%40 = phi i1 [ false, %30 ], [ false, %26 ], [ false, %3 ], [ %38, %34 ]
%41 = zext i1 %40 to i32
ret i32 %41
}

LLVM IR (-O2):
@.str = [27 x i8] c"%[^=]=%[^&]&%[^=]=%[^&]&%s\00"
@.str.1 = [9 x i8] c"username\00"
@.str.2 = [9 x i8] c"password\00"
@.str.3 = [13 x i8] c"commit=Login\00"
define i32 @read_login_data(i8* nocapture %0, i8** nocapture %1, i8** nocapture writeonly %2) {
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
store i8* %10, i8** %1
%11 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
store i8* %11, i8** %2
%12 = load i8*, i8** %1
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %12, i8* %8, i8* %11, i8* %9)
%14 = icmp eq i32 %13, 5
br i1 %14, label %15, label %25
15: ; preds = %3
%16 = call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 32)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 32)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 32)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %21, %18, %15, %3
%26 = phi i32 [ 0, %18 ], [ 0, %15 ], [ 0, %3 ], [ %24, %21 ]
ret i32 %26
}