#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 **authcopyargv(int, char **, char **);
int /*<<< orphan*/ authexit(int);
int /*<<< orphan*/ execv(char *, char **);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
void authmod_success(int argc, char **argv, const char *a) {
  char **vec, *prog;
  char *b;
  vec = authcopyargv(argc - 1, argv + 1, &prog);
  if (!prog)
    authexit(1);
  b = malloc(sizeof("AUTHENTICATED=") + strlen(a));
  if (!b) {
    perror("malloc");
    authexit(1);
  }
  strcat(strcpy(b, "AUTHENTICATED="), a);
  putenv(b);
  execv(prog, vec);
  perror(prog);
  authexit(1);
}


x86 assembly (clang, -O0):
<authmod_success>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
lea    -0x28(%rbp),%rdx
call   1080 <authcopyargv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11d3 <authmod_success+0x43>
mov    $0x1,%edi
call   1040 <authexit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
cltq
add    $0xf,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    120e <authmod_success+0x7e>
lea    0xe01(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
mov    -0x30(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1060 <putenv@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10b0 <execv@plt>
mov    -0x28(%rbp),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<authmod_success>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
add    $0xffffffff,%edi
add    $0x8,%rsi
lea    0x8(%rsp),%rdx
call   1080 <authcopyargv@plt>
mov    %rax,%r14
cmpq   $0x0,0x8(%rsp)
jne    11c2 <authmod_success+0x32>
mov    $0x1,%edi
call   1040 <authexit@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0xf(%rax),%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11f0 <authmod_success+0x60>
lea    0xe1f(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
lea    0xe10(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <putenv@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
call   10b0 <execv@plt>
mov    0x8(%rsp),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   1040 <authexit@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
@.str.1 = [15 x i8] c"AUTHENTICATED=\00"
define void @authmod_success(i32 %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = add nsw i32 %0, -1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = call i8** @authcopyargv(i32 %6, i8** %7, i8** %4)
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @authexit(i32 1)
br label %13
13: ; preds = %11, %3
%14 = call i32 @strlen(i8* %2)
%15 = add i32 %14, 15
%16 = call i8* @malloc(i32 %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @authexit(i32 1)
br label %21
21: ; preds = %18, %13
%22 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @strcat(i32 %22, i8* %2)
%24 = call i32 @putenv(i8* %16)
%25 = load i8*, i8** %4
%26 = call i32 @execv(i8* %25, i8** %8)
%27 = load i8*, i8** %4
%28 = call i32 @perror(i8* %27)
%29 = call i32 @authexit(i32 1)
ret void
}