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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ gethostname(char *, int);
int rad_auth(char *, char *, int, char *, char *, char *);
char *rad_auth_errstr();
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  int rc;
  char username[32], password[32], hostname[32];
  char vp[32 + 22];
  if (argc != 3) {
    fprintf(stdout, "<user> <pw>: ");
    fscanf(stdin, "%31s %31s", username, password);
  } else {
    strncpy(username, argv[1], 31);
    strncpy(password, argv[2], 31);
  }
  gethostname(hostname, 31);
  snprintf(vp, sizeof(vp), "Calling-Station-ID = %s", hostname);
  rc = rad_auth(username, password, 3, "servers", "dictionary.rfc2865", vp);
  if (rc < 0)
    fprintf(stderr, "Cannot authenticate: %s\n", rad_auth_errstr());
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11cc <main+0x5c>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    0xe4c(%rip),%rsi
call   1060 <fscanf@plt>
jmp    11f8 <main+0x88>
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
lea    -0x80(%rbp),%rdi
mov    $0x1f,%esi
call   1080 <gethostname@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x80(%rbp),%rcx
mov    $0x36,%esi
lea    0xdfb(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0xc0(%rbp),%r9
mov    $0x3,%edx
lea    0xdf3(%rip),%rcx
lea    0xdf4(%rip),%r8
call   1040 <rad_auth@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1283 <main+0x113>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    $0x0,%al
call   1090 <rad_auth_errstr@plt>
mov    -0xc4(%rbp),%edi
mov    %rax,%rdx
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
cmp    $0x3,%edi
jne    11a9 <main+0x39>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x20(%rsp),%rdi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
mov    0x10(%rbx),%rsi
mov    %rsp,%rdi
mov    $0x1f,%edx
call   1030 <strncpy@plt>
jmp    11dd <main+0x6d>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %rsp,%rcx
call   1060 <fscanf@plt>
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1f,%esi
call   1080 <gethostname@plt>
lea    0xe22(%rip),%rdx
lea    0x60(%rsp),%r14
mov    %r14,%rdi
mov    $0x36,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
lea    0xe1e(%rip),%rcx
lea    0xe1f(%rip),%r8
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x3,%edx
mov    %r14,%r9
call   1040 <rad_auth@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1257 <main+0xe7>
mov    0x2d9d(%rip),%rax
mov    (%rax),%ebp
xor    %eax,%eax
call   1090 <rad_auth_errstr@plt>
lea    0xe00(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %ebx,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [14 x i8] c"<user> <pw>: \00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"%31s %31s\00"
@.str.2 = [24 x i8] c"Calling-Station-ID = %s\00"
@.str.3 = [8 x i8] c"servers\00"
@.str.4 = [19 x i8] c"dictionary.rfc2865\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Cannot authenticate: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = alloca [54 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%19 = call i32 @fscanf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
br label %31
20: ; preds = %2
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strncpy(i8* %21, i8* %24, i32 31)
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @strncpy(i8* %26, i8* %29, i32 31)
br label %31
31: ; preds = %20, %13
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%33 = call i32 @gethostname(i8* %32, i32 31)
%34 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%36 = call i32 @snprintf(i8* %34, i32 54, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%39 = getelementptr inbounds [54 x i8], [54 x i8]* %10, i64 0, i64 0
%40 = call i32 @rad_auth(i8* %37, i8* %38, i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %39)
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %31
%44 = load i32, i32* @stderr
%45 = call i8* (...) @rad_auth_errstr()
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %43, %31
%48 = load i32, i32* %6
ret i32 %48
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [14 x i8] c"<user> <pw>: \00"
@stdin = global i32 0
@.str.1 = [10 x i8] c"%31s %31s\00"
@.str.2 = [24 x i8] c"Calling-Station-ID = %s\00"
@.str.3 = [8 x i8] c"servers\00"
@.str.4 = [19 x i8] c"dictionary.rfc2865\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Cannot authenticate: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [54 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [54 x i8], [54 x i8]* %6, i64 0, i64 0
%11 = icmp eq i32 %0, 3
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stdin
%16 = call i32 @fscanf(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %8)
br label %24
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strncpy(i8* %7, i8* %19, i32 31)
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @strncpy(i8* %8, i8* %22, i32 31)
br label %24
24: ; preds = %17, %12
%25 = call i32 @gethostname(i8* %9, i32 31)
%26 = call i32 @snprintf(i8* %10, i32 54, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%27 = call i32 @rad_auth(i8* %7, i8* %8, i32 3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i8* (...) @rad_auth_errstr()
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %29, %24
ret i32 %27
}