#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 */
int /*<<< orphan*/ auth_debug_login(int, char *, char const *);
int /*<<< orphan*/ authexit(int);
int /*<<< orphan*/ authmod(int, char **, char const *, char *, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
void authmod_login(int argc, char **argv, const char *service,
                   const char *userid, const char *passwd) {
  char *p = malloc(strlen(userid) + strlen(passwd) + 3);
  auth_debug_login(1, "username=%s", userid);
  auth_debug_login(2, "password=%s", passwd);
  if (!p) {
    perror("malloc");
    authexit(1);
  }
  strcat(strcat(strcat(strcpy(p, userid), "\n"), passwd), "\n");
  authmod(argc, argv, service, "login", p);
}


x86 assembly (clang, -O0):
<authmod_login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
mov    $0x1,%edi
lea    0xe2b(%rip),%rsi
call   1070 <auth_debug_login@plt>
mov    -0x28(%rbp),%rdx
mov    $0x2,%edi
lea    0xe22(%rip),%rsi
call   1070 <auth_debug_login@plt>
cmpq   $0x0,-0x30(%rbp)
jne    1210 <authmod_login+0x90>
lea    0xe17(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xdf9(%rip),%rsi
call   10a0 <strcat@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rsi
call   10a0 <strcat@plt>
mov    %eax,%edi
lea    0xde0(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x30(%rbp),%r8
lea    0xdc7(%rip),%rcx
call   1060 <authmod@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authmod_login>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
mov    %rcx,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbp
lea    0xe3c(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1070 <auth_debug_login@plt>
lea    0xe34(%rip),%rsi
mov    $0x2,%edi
mov    %r13,%rdx
call   1070 <auth_debug_login@plt>
test   %rbp,%rbp
je     1240 <authmod_login+0xc0>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe23(%rip),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   10a0 <strcat@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   10a0 <strcat@plt>
lea    0xe00(%rip),%rcx
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rbp,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <authmod@plt>
lea    0xdd1(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
jmp    11ea <authmod_login+0x6a>

LLVM IR (-O0):
@.str = [12 x i8] c"username=%s\00"
@.str.1 = [12 x i8] c"password=%s\00"
@.str.2 = [7 x i8] c"malloc\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"login\00"
define void @authmod_login(i32 %0, i8** %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %9
%13 = call i64 @strlen(i8* %12)
%14 = load i8*, i8** %10
%15 = call i64 @strlen(i8* %14)
%16 = add nsw i64 %13, %15
%17 = add nsw i64 %16, 3
%18 = call i8* @malloc(i64 %17)
store i8* %18, i8** %11
%19 = load i8*, i8** %9
%20 = call i32 @auth_debug_login(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %10
%22 = call i32 @auth_debug_login(i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %11
%24 = icmp ne i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %5
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @authexit(i32 1)
br label %28
28: ; preds = %25, %5
%29 = load i8*, i8** %11
%30 = load i8*, i8** %9
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = call i32 @strcat(i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %10
%34 = call i32 @strcat(i32 %32, i8* %33)
%35 = call i32 @strcat(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %6
%37 = load i8**, i8*** %7
%38 = load i8*, i8** %8
%39 = load i8*, i8** %11
%40 = call i32 @authmod(i32 %36, i8** %37, i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %39)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"username=%s\00"
@.str.1 = [12 x i8] c"password=%s\00"
@.str.2 = [7 x i8] c"malloc\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"login\00"
define void @authmod_login(i32 %0, i8** %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%8 = add i64 %6, 3
%9 = add i64 %8, %7
%10 = tail call i8* @malloc(i64 %9)
%11 = tail call i32 @auth_debug_login(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%12 = tail call i32 @auth_debug_login(i32 2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%13 = icmp eq i8* %10, null
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 @authexit(i32 1)
br label %17
17: ; preds = %14, %5
%18 = tail call i32 @strcpy(i8* %10, i8* %3)
%19 = tail call i32 @strcat(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @strcat(i32 %19, i8* %4)
%21 = tail call i32 @strcat(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @authmod(i32 %0, i8** %1, i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %10)
ret void
}