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

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void ask_auth_fn(const char *server, const char *share, char *workgroup,
                 int wgmaxlen, char *username, int unmaxlen, char *password,
                 int pwmaxlen) {
  char temp[128];
  fprintf(stdout, "Need password for //%s/%s\n", server, share);
  fprintf(stdout, "Enter workgroup: [%s] ", workgroup);
  fgets(temp, sizeof(temp), stdin);
  if (temp[strlen(temp) - 1] == 0x0a)
    temp[strlen(temp) - 1] = 0x00;
  if (temp[0])
    strncpy(workgroup, temp, wgmaxlen - 1);
  fprintf(stdout, "Enter username: [%s] ", username);
  fgets(temp, sizeof(temp), stdin);
  if (temp[strlen(temp) - 1] == 0x0a)
    temp[strlen(temp) - 1] = 0x00;
  if (temp[0])
    strncpy(username, temp, unmaxlen - 1);
  fprintf(stdout, "Enter password: [%s] ", password);
  fgets(temp, sizeof(temp), stdin);
  if (temp[strlen(temp) - 1] == 0x0a)
    temp[strlen(temp) - 1] = 0x00;
  if (temp[0])
    strncpy(password, temp, pwmaxlen - 1);
}


x86 assembly (clang, -O0):
<ask_auth_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0xb0(%rbp),%rdi
mov    0x2e37(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    11f8 <ask_auth_fn+0xb8>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
cmpb   $0x0,-0xb0(%rbp)
je     121b <ask_auth_fn+0xdb>
mov    -0x18(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0xb0(%rbp),%rdi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    128b <ask_auth_fn+0x14b>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
cmpb   $0x0,-0xb0(%rbp)
je     12ae <ask_auth_fn+0x16e>
mov    -0x28(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    -0x2c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xd86(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0xb0(%rbp),%rdi
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1050 <fgets@plt>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    131e <ask_auth_fn+0x1de>
lea    -0xb0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0xb0(%rbp,%rax,1)
cmpb   $0x0,-0xb0(%rbp)
je     1341 <ask_auth_fn+0x201>
mov    0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    0x18(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_auth_fn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9d,%r15d
mov    %r8,%r14
mov    %ecx,%ebp
mov    %rdx,%r12
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2e6f(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe8c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xe95(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    11c9 <ask_auth_fn+0x89>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
cmpb   $0x0,(%rsp)
je     11df <ask_auth_fn+0x9f>
add    $0xffffffff,%ebp
mov    %rsp,%rsi
mov    %r12,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    0x0(%r13),%edi
lea    0xe48(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2ded(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    122b <ask_auth_fn+0xeb>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0xc0(%rsp),%r12
cmpb   $0x0,(%rsp)
je     124b <ask_auth_fn+0x10b>
add    $0xffffffff,%r15d
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    0x0(%r13),%edi
lea    0xdf2(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1290 <ask_auth_fn+0x150>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
cmpb   $0x0,(%rsp)
je     12ab <ask_auth_fn+0x16b>
mov    0xc8(%rsp),%edx
add    $0xffffffff,%edx
mov    %rsp,%rsi
mov    %r12,%rdi
call   1030 <strncpy@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [27 x i8] c"Need password for //%s/%s\0A\00"
@.str.1 = [23 x i8] c"Enter workgroup: [%s] \00"
@stdin = global i32 0
@.str.2 = [22 x i8] c"Enter username: [%s] \00"
@.str.3 = [22 x i8] c"Enter password: [%s] \00"
define void @ask_auth_fn(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4, i32 %5, i8* %6, i32 %7) {
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca [128 x i8]
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i32 %5, i32* %14
store i8* %6, i8** %15
store i32 %7, i32* %16
%18 = load i32, i32* @stdout
%19 = load i8*, i8** %9
%20 = load i8*, i8** %10
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i32, i32* @stdout
%23 = load i8*, i8** %11
%24 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 128, i32 %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %42
36: ; preds = %8
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %40
store i8 0, i8* %41
br label %42
42: ; preds = %36, %8
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %42
%47 = load i8*, i8** %11
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%49 = load i32, i32* %12
%50 = sub nsw i32 %49, 1
%51 = call i32 @strncpy(i8* %47, i8* %48, i32 %50)
br label %52
52: ; preds = %46, %42
%53 = load i32, i32* @stdout
%54 = load i8*, i8** %13
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %54)
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%57 = load i32, i32* @stdin
%58 = call i32 @fgets(i8* %56, i32 128, i32 %57)
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = sub nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %67, label %73
67: ; preds = %52
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%69 = call i32 @strlen(i8* %68)
%70 = sub nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %71
store i8 0, i8* %72
br label %73
73: ; preds = %67, %52
%74 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%75 = load i8, i8* %74
%76 = icmp ne i8 %75, 0
br i1 %76, label %77, label %83
77: ; preds = %73
%78 = load i8*, i8** %13
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%80 = load i32, i32* %14
%81 = sub nsw i32 %80, 1
%82 = call i32 @strncpy(i8* %78, i8* %79, i32 %81)
br label %83
83: ; preds = %77, %73
%84 = load i32, i32* @stdout
%85 = load i8*, i8** %15
%86 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %84, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %85)
%87 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%88 = load i32, i32* @stdin
%89 = call i32 @fgets(i8* %87, i32 128, i32 %88)
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%91 = call i32 @strlen(i8* %90)
%92 = sub nsw i32 %91, 1
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %93
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = icmp eq i32 %96, 10
br i1 %97, label %98, label %104
98: ; preds = %83
%99 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%100 = call i32 @strlen(i8* %99)
%101 = sub nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 %102
store i8 0, i8* %103
br label %104
104: ; preds = %98, %83
%105 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%106 = load i8, i8* %105
%107 = icmp ne i8 %106, 0
br i1 %107, label %108, label %114
108: ; preds = %104
%109 = load i8*, i8** %15
%110 = getelementptr inbounds [128 x i8], [128 x i8]* %17, i64 0, i64 0
%111 = load i32, i32* %16
%112 = sub nsw i32 %111, 1
%113 = call i32 @strncpy(i8* %109, i8* %110, i32 %112)
br label %114
114: ; preds = %108, %104
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [27 x i8] c"Need password for //%s/%s\0A\00"
@.str.1 = [23 x i8] c"Enter workgroup: [%s] \00"
@stdin = global i32 0
@.str.2 = [22 x i8] c"Enter username: [%s] \00"
@.str.3 = [22 x i8] c"Enter password: [%s] \00"
define void @ask_auth_fn(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4, i32 %5, i8* %6, i32 %7) {
%9 = alloca [128 x i8]
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%11 = load i32, i32* @stdout
%12 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%13 = load i32, i32* @stdout
%14 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%15 = load i32, i32* @stdin
%16 = call i32 @fgets(i8* %10, i32 128, i32 %15)
%17 = call i32 @strlen(i8* %10)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %28
23: ; preds = %8
%24 = call i32 @strlen(i8* %10)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %23, %8
%29 = load i8, i8* %10
%30 = icmp eq i8 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = add nsw i32 %3, -1
%33 = call i32 @strncpy(i8* %2, i8* %10, i32 %32)
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* @stdout
%36 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%37 = load i32, i32* @stdin
%38 = call i32 @fgets(i8* %10, i32 128, i32 %37)
%39 = call i32 @strlen(i8* %10)
%40 = add nsw i32 %39, -1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 10
br i1 %44, label %45, label %50
45: ; preds = %34
%46 = call i32 @strlen(i8* %10)
%47 = add nsw i32 %46, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %48
store i8 0, i8* %49
br label %50
50: ; preds = %45, %34
%51 = load i8, i8* %10
%52 = icmp eq i8 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = add nsw i32 %5, -1
%55 = call i32 @strncpy(i8* %4, i8* %10, i32 %54)
br label %56
56: ; preds = %53, %50
%57 = load i32, i32* @stdout
%58 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%59 = load i32, i32* @stdin
%60 = call i32 @fgets(i8* %10, i32 128, i32 %59)
%61 = call i32 @strlen(i8* %10)
%62 = add nsw i32 %61, -1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = icmp eq i8 %65, 10
br i1 %66, label %67, label %72
67: ; preds = %56
%68 = call i32 @strlen(i8* %10)
%69 = add nsw i32 %68, -1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %70
store i8 0, i8* %71
br label %72
72: ; preds = %67, %56
%73 = load i8, i8* %10
%74 = icmp eq i8 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %72
%76 = add nsw i32 %7, -1
%77 = call i32 @strncpy(i8* %6, i8* %10, i32 %76)
br label %78
78: ; preds = %75, %72
ret void
}