#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 char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ LC_CTYPE;
int /*<<< orphan*/ free(char *);
char *passwd_response(char const *, char const *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
char *striso8859_1(char const *);
int /*<<< orphan*/ wprintf(char *, ...);
int main(void) {
  setlocale(LC_CTYPE, "");
  const char *challenge = "1234567z";
  const wchar_t *password = L"äbc";
  wchar_t *iso_password = striso8859_1(password);
  char *response = passwd_response(challenge, password);
  wprintf(L"          password: %ls\n", password);
  wprintf(L"      new password: %ls\n", iso_password);
  wprintf(L"\n");
  wprintf(L"         challenge: %s\n", challenge);
  wprintf(L"\n");
  wprintf(L"   static response: %ls\n",
          L"1234567z-9e224a41eeefa284df7bb0f26c2913e2");
  wprintf(L"          response: %s\n", response);
  free(iso_password);
  free(response);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe85(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe86(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <striso8859_1@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <passwd_response@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    -0x20(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
lea    0xf69(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
lea    0xf49(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
lea    0xf43(%rip),%rdi
lea    0xfa0(%rip),%rsi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    -0x28(%rbp),%rsi
lea    0x1036(%rip),%rdi
mov    $0x0,%al
call   1050 <wprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea0(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
call   1040 <striso8859_1@plt>
mov    %rax,%r14
lea    0xe7a(%rip),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <passwd_response@plt>
mov    %rax,%r12
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
lea    0xed4(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
lea    0xf7f(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <wprintf@plt>
lea    0xf16(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <wprintf@plt>
lea    0xf5b(%rip),%rdi
lea    0xfb8(%rip),%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
lea    0x1052(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <wprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"1234567z\00"
@.str.2 = [4 x i32] [i32 228, i32 98, i32 99, i32 0]
@.str.3 = [25 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 112, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.4 = [25 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 110, i32 101, i32 119, i32 32, i32 112, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.5 = [2 x i32] [i32 10, i32 0]
@.str.6 = [24 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 99, i32 104, i32 97, i32 108, i32 108, i32 101, i32 110, i32 103, i32 101, i32 58, i32 32, i32 37, i32 115, i32 10, i32 0]
@.str.7 = [25 x i32] [i32 32, i32 32, i32 32, i32 115, i32 116, i32 97, i32 116, i32 105, i32 99, i32 32, i32 114, i32 101, i32 115, i32 112, i32 111, i32 110, i32 115, i32 101, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.8 = [42 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 122, i32 45, i32 57, i32 101, i32 50, i32 50, i32 52, i32 97, i32 52, i32 49, i32 101, i32 101, i32 101, i32 102, i32 97, i32 50, i32 56, i32 52, i32 100, i32 102, i32 55, i32 98, i32 98, i32 48, i32 102, i32 50, i32 54, i32 99, i32 50, i32 57, i32 49, i32 51, i32 101, i32 50, i32 0]
@.str.9 = [24 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 114, i32 101, i32 115, i32 112, i32 111, i32 110, i32 115, i32 101, i32 58, i32 32, i32 37, i32 115, i32 10, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = load i32, i32* @LC_CTYPE
%7 = call i32 @setlocale(i32 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* bitcast ([4 x i32]* @.str.2 to i8*), i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @striso8859_1(i8* %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %2
%11 = load i8*, i8** %3
%12 = call i8* @passwd_response(i8* %10, i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %3
%14 = call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.3 to i8*), i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.4 to i8*), i8* %15)
%17 = call i32 (i8*, ...) @wprintf(i8* bitcast ([2 x i32]* @.str.5 to i8*))
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @wprintf(i8* bitcast ([24 x i32]* @.str.6 to i8*), i8* %18)
%20 = call i32 (i8*, ...) @wprintf(i8* bitcast ([2 x i32]* @.str.5 to i8*))
%21 = call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.7 to i8*), i32* getelementptr inbounds ([42 x i32], [42 x i32]* @.str.8, i64 0, i64 0))
%22 = load i8*, i8** %5
%23 = call i32 (i8*, ...) @wprintf(i8* bitcast ([24 x i32]* @.str.9 to i8*), i8* %22)
%24 = load i8*, i8** %4
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
ret i32 0
}

LLVM IR (-O2):
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"1234567z\00"
@.str.2 = [4 x i32] [i32 228, i32 98, i32 99, i32 0]
@.str.3 = [25 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 112, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.4 = [25 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 110, i32 101, i32 119, i32 32, i32 112, i32 97, i32 115, i32 115, i32 119, i32 111, i32 114, i32 100, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.5 = [2 x i32] [i32 10, i32 0]
@.str.6 = [24 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 99, i32 104, i32 97, i32 108, i32 108, i32 101, i32 110, i32 103, i32 101, i32 58, i32 32, i32 37, i32 115, i32 10, i32 0]
@.str.7 = [25 x i32] [i32 32, i32 32, i32 32, i32 115, i32 116, i32 97, i32 116, i32 105, i32 99, i32 32, i32 114, i32 101, i32 115, i32 112, i32 111, i32 110, i32 115, i32 101, i32 58, i32 32, i32 37, i32 108, i32 115, i32 10, i32 0]
@.str.8 = [42 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 122, i32 45, i32 57, i32 101, i32 50, i32 50, i32 52, i32 97, i32 52, i32 49, i32 101, i32 101, i32 101, i32 102, i32 97, i32 50, i32 56, i32 52, i32 100, i32 102, i32 55, i32 98, i32 98, i32 48, i32 102, i32 50, i32 54, i32 99, i32 50, i32 57, i32 49, i32 51, i32 101, i32 50, i32 0]
@.str.9 = [24 x i32] [i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 114, i32 101, i32 115, i32 112, i32 111, i32 110, i32 115, i32 101, i32 58, i32 32, i32 37, i32 115, i32 10, i32 0]
define i32 @main() {
%1 = load i32, i32* @LC_CTYPE
%2 = tail call i32 @setlocale(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @striso8859_1(i8* bitcast ([4 x i32]* @.str.2 to i8*))
%4 = tail call i8* @passwd_response(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* bitcast ([4 x i32]* @.str.2 to i8*))
%5 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.3 to i8*), i8* bitcast ([4 x i32]* @.str.2 to i8*))
%6 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.4 to i8*), i8* %3)
%7 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([2 x i32]* @.str.5 to i8*))
%8 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([24 x i32]* @.str.6 to i8*), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([2 x i32]* @.str.5 to i8*))
%10 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([25 x i32]* @.str.7 to i8*), i32* getelementptr inbounds ([42 x i32], [42 x i32]* @.str.8, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @wprintf(i8* bitcast ([24 x i32]* @.str.9 to i8*), i8* %4)
%12 = tail call i32 @free(i8* %3)
%13 = tail call i32 @free(i8* %4)
ret i32 0
}