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

/* Variables and functions */
int /*<<< orphan*/ sha1_core(char *, char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand(int);
int do_sha1_2(int *pbuf) {
  int i;
  char infilename[30];
  char outfilename[30];
  srand(6);
  for (i = 0; i < 1; i++) {
    sprintf(infilename, "./file%04d.hex", i);
    sprintf(outfilename, "./sha1_file%04d.hex", i);
    sha1_core(infilename, outfilename, pbuf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_sha1_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x6,%edi
call   1030 <srand@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    119c <do_sha1_2+0x6c>
lea    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe9b(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x50(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe97(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1040 <sha1_core@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <do_sha1_2+0x1d>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_sha1_2>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r15
mov    $0x6,%edi
call   1030 <srand@plt>
lea    0xeb3(%rip),%rsi
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %edx,%edx
call   1050 <sprintf@plt>
lea    0xeac(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %edx,%edx
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <sha1_core@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"./file%04d.hex\00"
@.str.1 = [20 x i8] c"./sha1_file%04d.hex\00"
define i32 @do_sha1_2(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [30 x i8]
%5 = alloca [30 x i8]
store i32* %0, i32** %2
%6 = call i32 @srand(i32 6)
store i32 0, i32* %3
br label %7
7: ; preds = %21, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%15 = load i32, i32* %3
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32 @sha1_core(i8* %17, i8* %18, i32* %19)
br label %21
21: ; preds = %10
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %7
24: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"./file%04d.hex\00"
@.str.1 = [20 x i8] c"./sha1_file%04d.hex\00"
define i32 @do_sha1_2(i32* %0) {
%2 = alloca [30 x i8]
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @srand(i32 6)
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 0)
%9 = call i32 @sha1_core(i8* %4, i8* %5, i32* %0)
ret i32 0
}