#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*/ sprintf(char *, char *, int);
void drawper(int file_send, int file_total, char *spOut) {
  if (NULL == spOut) {
    return;
  }
  static int iCrlmm = 0;
  int iPer = file_send * 100 / file_total;
  if (file_send == file_total) {
    sprintf(spOut, "[ %d%]\r", iPer);
  } else if (iCrlmm == 0) {
    sprintf(spOut, "[| %d%]\r", iPer);
  } else if (iCrlmm == 1) {
    sprintf(spOut, "[/ %d%]\r", iPer);
  } else if (iCrlmm == 2) {
    sprintf(spOut, "[- %d%]\r", iPer);
  } else if (iCrlmm == 3) {
    sprintf(spOut, "[\\ %d%]\r", iPer);
  }
  if (iCrlmm == 3) {
    iCrlmm = 0;
  } else {
    iCrlmm++;
  }
}


x86 assembly (clang, -O0):
<drawper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1133 <drawper+0x23>
jmp    1230 <drawper+0x120>
imul   $0x64,-0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1162 <drawper+0x52>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xea8(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1205 <drawper+0xf5>
cmpl   $0x0,0x2ec3(%rip)
jne    1187 <drawper+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8b(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1200 <drawper+0xf0>
cmpl   $0x1,0x2e9e(%rip)
jne    11ac <drawper+0x9c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe6f(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11fb <drawper+0xeb>
cmpl   $0x2,0x2e79(%rip)
jne    11d1 <drawper+0xc1>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe53(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11f6 <drawper+0xe6>
cmpl   $0x3,0x2e54(%rip)
jne    11f1 <drawper+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe37(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11f6 <drawper+0xe6>
jmp    11fb <drawper+0xeb>
jmp    1200 <drawper+0xf0>
jmp    1205 <drawper+0xf5>
cmpl   $0x3,0x2e20(%rip)
jne    1221 <drawper+0x111>
movl   $0x0,0x2e10(%rip)
jmp    1230 <drawper+0x120>
mov    0x2e05(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2dfc(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawper>:
test   %rdx,%rdx
je     1175 <drawper+0x65>
push   %rax
mov    %rdx,%rcx
imul   $0x64,%edi,%eax
cltd
idiv   %esi
cmp    %esi,%edi
jne    112c <drawper+0x1c>
lea    0xed6(%rip),%rsi
jmp    1150 <drawper+0x40>
movslq 0x2ef9(%rip),%rdx
cmp    $0x2,%rdx
ja     1149 <drawper+0x39>
lea    0xeec(%rip),%rdi
movslq (%rdi,%rdx,4),%rsi
add    %rdi,%rsi
jmp    1150 <drawper+0x40>
lea    0xed3(%rip),%rsi
mov    %rcx,%rdi
mov    %eax,%edx
call   1030 <sprintf@plt>
mov    0x2ecc(%rip),%eax
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%eax
cmovne %ecx,%edx
mov    %edx,0x2ebb(%rip)
add    $0x8,%rsp
ret

LLVM IR (-O0):
@drawper.iCrlmm = internal global i32 0
@.str = [8 x i8] c"[ %d%]\0D\00"
@.str.1 = [9 x i8] c"[| %d%]\0D\00"
@.str.2 = [9 x i8] c"[/ %d%]\0D\00"
@.str.3 = [9 x i8] c"[- %d%]\0D\00"
@.str.4 = [9 x i8] c"[\\ %d%]\0D\00"
define void @drawper(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = icmp eq i8* null, %8
br i1 %9, label %10, label %11
10: ; preds = %3
br label %62
11: ; preds = %3
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 100
%14 = load i32, i32* %5
%15 = sdiv i32 %13, %14
store i32 %15, i32* %7
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %11
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %55
23: ; preds = %11
%24 = load i32, i32* @drawper.iCrlmm
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %54
30: ; preds = %23
%31 = load i32, i32* @drawper.iCrlmm
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %53
37: ; preds = %30
%38 = load i32, i32* @drawper.iCrlmm
%39 = icmp eq i32 %38, 2
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load i8*, i8** %6
%42 = load i32, i32* %7
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %52
44: ; preds = %37
%45 = load i32, i32* @drawper.iCrlmm
%46 = icmp eq i32 %45, 3
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = load i32, i32* %7
%50 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %47, %44
br label %52
52: ; preds = %51, %40
br label %53
53: ; preds = %52, %33
br label %54
54: ; preds = %53, %26
br label %55
55: ; preds = %54, %19
%56 = load i32, i32* @drawper.iCrlmm
%57 = icmp eq i32 %56, 3
br i1 %57, label %58, label %59
58: ; preds = %55
store i32 0, i32* @drawper.iCrlmm
br label %62
59: ; preds = %55
%60 = load i32, i32* @drawper.iCrlmm
%61 = add nsw i32 %60, 1
store i32 %61, i32* @drawper.iCrlmm
br label %62
62: ; preds = %10, %59, %58
ret void
}

LLVM IR (-O2):
@drawper.iCrlmm = internal unnamed_addr global i32 0
@.str = [8 x i8] c"[ %d%]\0D\00"
@.str.1 = [9 x i8] c"[| %d%]\0D\00"
@.str.2 = [9 x i8] c"[/ %d%]\0D\00"
@.str.3 = [9 x i8] c"[- %d%]\0D\00"
@.str.4 = [9 x i8] c"[\\ %d%]\0D\00"
@reltable.drawper = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.drawper to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.drawper to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.drawper to i64)) to i32)]
define void @drawper(i32 %0, i32 %1, i8* writeonly %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = mul nsw i32 %0, 100
%7 = sdiv i32 %6, %1
%8 = icmp eq i32 %0, %1
br i1 %8, label %16, label %9
9: ; preds = %5
%10 = load i32, i32* @drawper.iCrlmm
%11 = icmp ult i32 %10, 3
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = sext i32 %10 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.drawper to i8*), i64 %14)
br label %16
16: ; preds = %9, %12, %5
%17 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %5 ], [ %15, %12 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %9 ]
%18 = tail call i32 @sprintf(i8* %2, i8* dereferenceable(1) %17, i32 %7)
%19 = load i32, i32* @drawper.iCrlmm
%20 = icmp eq i32 %19, 3
%21 = add nsw i32 %19, 1
%22 = select i1 %20, i32 0, i32 %21
store i32 %22, i32* @drawper.iCrlmm
br label %23
23: ; preds = %3, %16
ret void
}