#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void get_progress(char *progress, int i, int nodes, int steps) {
  int progress_step = (nodes / steps);
  if (i % progress_step == 0) {
    strcpy(progress, "[");
    for (int p = 1; p < (i / progress_step); p++)
      strcat(progress, "=");
    if ((i < nodes - progress_step) && (i >= progress_step))
      strcat(progress, ">");
    for (int q = (i / progress_step); q < steps - 1; q++)
      strcat(progress, "-");
    strcat(progress, "]");
  }
}


x86 assembly (clang, -O0):
<get_progress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    1214 <get_progress+0xf4>
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    119e <get_progress+0x7e>
mov    -0x8(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1166 <get_progress+0x46>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11cb <get_progress+0xab>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     11cb <get_progress+0xab>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcat@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1204 <get_progress+0xe4>
mov    -0x8(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d5 <get_progress+0xb5>
mov    -0x8(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strcat@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_progress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r13d
mov    %edx,%eax
cltd
idiv   %ecx
mov    %eax,%ebp
mov    %esi,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1150 <get_progress+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r14
mov    %eax,%ebx
mov    %esi,0xc(%rsp)
mov    %rcx,0x10(%rsp)
lea    0xe9b(%rip),%rsi
call   1030 <strcpy@plt>
cmp    $0x2,%ebx
jl     1191 <get_progress+0x71>
lea    -0x1(%rbx),%r12d
lea    0xe88(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%r12d
jne    1180 <get_progress+0x60>
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
jg     11b0 <get_progress+0x90>
sub    %ebp,%r13d
cmp    %eax,%r13d
jle    11b0 <get_progress+0x90>
lea    0xe5c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    0x10(%rsp),%rcx
lea    -0x1(%rcx),%eax
cmp    %eax,%ebx
jge    11e0 <get_progress+0xc0>
not    %ebx
add    %ecx,%ebx
lea    0xe3f(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%ebx
jne    11d0 <get_progress+0xb0>
lea    0xe21(%rip),%rsi
mov    %r14,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <strcat@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"[\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [2 x i8] c">\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [2 x i8] c"]\00"
define void @get_progress(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = sdiv i32 %2, %3
%6 = srem i32 %1, %5
%7 = sdiv i32 %1, %5
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %34
9: ; preds = %4
%10 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp sgt i32 %7, 1
br i1 %11, label %17, label %12
12: ; preds = %17, %9
%13 = sub nsw i32 %2, %5
%14 = icmp sle i32 %13, %1
%15 = icmp sgt i32 %5, %1
%16 = or i1 %15, %14
br i1 %16, label %24, label %22
17: ; preds = %9, %17
%18 = phi i32 [ %20, %17 ], [ 1, %9 ]
%19 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %7
br i1 %21, label %12, label %17
22: ; preds = %12
%23 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %12
%25 = add i32 %3, -1
%26 = icmp slt i32 %7, %25
br i1 %26, label %29, label %27
27: ; preds = %29, %24
%28 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %34
29: ; preds = %24, %29
%30 = phi i32 [ %32, %29 ], [ %7, %24 ]
%31 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = add i32 %30, 1
%33 = icmp eq i32 %32, %25
br i1 %33, label %27, label %29
34: ; preds = %27, %4
ret void
}