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

/* Variables and functions */
int auth_user(char *, char *);
int /*<<< orphan*/ http_base64_decode(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *, ...);
char *strchr(char *, char);
int check_authorization(char *pszciphertext) {
  printf("cipher is %s\n", pszciphertext);
  char *user;
  char *pwd;
  int uname_len;
  char *pcipher;
  char szplaintext[256] = {0};
  http_base64_decode(pszciphertext, szplaintext, sizeof(szplaintext));
  pwd = strchr(szplaintext, ':');
  uname_len = (pwd++) - szplaintext;
  szplaintext[uname_len] = '\0';
  user = szplaintext;
  printf("user is %s,pwd is **%s**", user, pwd);
  return auth_user(user, pwd);
}


x86 assembly (clang, -O0):
<check_authorization>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x100,%edx
call   1060 <http_base64_decode@plt>
lea    -0x130(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
lea    -0x130(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x130(%rbp,%rax,1)
lea    -0x130(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <auth_user@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_authorization>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x100,%edx
call   1050 <http_base64_decode@plt>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rbx
sub    %r14d,%eax
cltq
movb   $0x0,(%rsp,%rax,1)
lea    0xe12(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <auth_user@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"cipher is %s\0A\00"
@.str.1 = [25 x i8] c"user is %s,pwd is **%s**\00"
define i32 @check_authorization(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [256 x i8]
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = bitcast [256 x i8]* %7 to i8*
%11 = load i8*, i8** %2
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%13 = call i32 @http_base64_decode(i8* %11, i8* %12, i32 256)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%15 = call i8* @strchr(i8* %14, i8 signext 58)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%19 = ptrtoint i8* %16 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8* %26, i8** %3
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28)
%30 = load i8*, i8** %3
%31 = load i8*, i8** %4
%32 = call i32 @auth_user(i8* %30, i8* %31)
ret i32 %32
}

LLVM IR (-O2):
@.str = [14 x i8] c"cipher is %s\0A\00"
@.str.1 = [25 x i8] c"user is %s,pwd is **%s**\00"
define i32 @check_authorization(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = call i32 @http_base64_decode(i8* %0, i8* %4, i32 256)
%6 = call i8* @strchr(i8* %4, i8 signext 58)
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = ptrtoint i8* %6 to i64
%9 = ptrtoint [256 x i8]* %2 to i64
%10 = sub i64 %8, %9
%11 = shl i64 %10, 32
%12 = ashr exact i64 %11, 32
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %12
store i8 0, i8* %13
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %7)
%15 = call i32 @auth_user(i8* %4, i8* %7)
ret i32 %15
}