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

/* Variables and functions */
int SHA1_Init(int /*<<< orphan*/ *);
int SHA1_Update(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  SHA_CTX sha_ctx;
  int result;
  char str[] = "ABCDE";
  result = SHA1_Init(&sha_ctx);
  if (result == 1) {
    printf("SHA1_Init success!\n");
  } else {
    printf("SHA1_Init error!\n");
    return -1;
  }
  result = SHA1_Update(&sha_ctx, str, strlen(str));
  if (result == 1) {
    printf("SHA1_Update success!\n");
  } else {
    printf("SHA1_Update error!\n");
    return -2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeab(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xea5(%rip),%ax
mov    %ax,-0xe(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <SHA1_Init@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    118a <main+0x4a>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
jmp    11a2 <main+0x62>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <main+0xbf>
lea    -0x12(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    -0x8(%rbp),%rdi
call   1050 <SHA1_Update@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11e0 <main+0xa0>
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
jmp    11f8 <main+0xb8>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11ff <main+0xbf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movw   $0x45,0x8(%rsp)
movl   $0x44434241,0x4(%rsp)
44
lea    0xc(%rsp),%rdi
call   1060 <SHA1_Init@plt>
cmp    $0x1,%eax
jne    11ad <main+0x6d>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <SHA1_Update@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
lea    0xea3(%rip),%rax
lea    0xe89(%rip),%rdi
cmove  %rax,%rdi
lea    (%rcx,%rcx,1),%ebx
add    $0xfffffffe,%ebx
jmp    11b9 <main+0x79>
mov    $0xffffffff,%ebx
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [6 x i8] c"ABCDE\00"
@.str = [20 x i8] c"SHA1_Init success!\0A\00"
@.str.1 = [18 x i8] c"SHA1_Init error!\0A\00"
@.str.2 = [22 x i8] c"SHA1_Update success!\0A\00"
@.str.3 = [20 x i8] c"SHA1_Update error!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
store i32 0, i32* %1
%5 = bitcast [6 x i8]* %4 to i8*
%6 = call i32 @SHA1_Init(i32* %2)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %25
13: ; preds = %9
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @SHA1_Update(i32* %2, i8* %14, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %24
22: ; preds = %13
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
store i32 -2, i32* %1
br label %25
24: ; preds = %20
store i32 0, i32* %1
br label %25
25: ; preds = %24, %22, %11
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@__const.main.str = [6 x i8] c"ABCDE\00"
@str = [17 x i8] c"SHA1_Init error!\00"
@str.4 = [19 x i8] c"SHA1_Init success!\00"
@str.5 = [19 x i8] c"SHA1_Update error!\00"
@str.6 = [21 x i8] c"SHA1_Update success!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = call i32 @SHA1_Init(i32* %1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.4, i64 0, i64 0))
%9 = call i32 @strlen(i8* %4)
%10 = call i32 @SHA1_Update(i32* %1, i8* %4, i32 %9)
%11 = icmp eq i32 %10, 1
%12 = select i1 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0)
%13 = select i1 %11, i32 0, i32 -2
br label %14
14: ; preds = %0, %7
%15 = phi i8* [ %12, %7 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0), %0 ]
%16 = phi i32 [ %13, %7 ], [ -1, %0 ]
%17 = call i32 @puts(i8* dereferenceable(1) %15)
ret i32 %16
}