#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
void print_progress(int thr_id, int index, int max) {
  int step = max / 10;
  if (thr_id != 0)
    return;
  if (index == 0) {
    printf("   Progress : ");
    fflush(stdout);
  }
  if (index % step == 0) {
    printf("#");
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<print_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     114e <print_progress+0x2e>
jmp    119c <print_progress+0x7c>
cmpl   $0x0,-0x8(%rbp)
jne    1172 <print_progress+0x52>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    119c <print_progress+0x7c>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_progress>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
jne    1177 <print_progress+0x47>
mov    %esi,%ebp
movslq %edx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
test   %esi,%esi
jne    116e <print_progress+0x3e>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     117e <print_progress+0x4e>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@.str = [15 x i8] c" Progress : \00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"#\00"
define void @print_progress(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sdiv i32 %8, 10
store i32 %9, i32* %7
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
br label %29
13: ; preds = %3
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @stdout
%19 = call i32 @fflush(i32 %18)
br label %20
20: ; preds = %16, %13
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = srem i32 %21, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
br label %29
29: ; preds = %12, %25, %20
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c" Progress : \00"
@stdout = global i32 0
define void @print_progress(i32 %0, i32 %1, i32 %2) {
%4 = sdiv i32 %2, 10
%5 = icmp eq i32 %0, 0
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = icmp eq i32 %1, 0
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = tail call i32 @fflush(i32 %10)
br label %12
12: ; preds = %8, %6
%13 = srem i32 %1, %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @putchar(i32 35)
%17 = load i32, i32* @stdout
%18 = tail call i32 @fflush(i32 %17)
br label %19
19: ; preds = %12, %15, %3
ret void
}