#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*/ print(char *);
int /*<<< orphan*/ printNewLine();
int /*<<< orphan*/ printNum(int);
int /*<<< orphan*/ sleep(int);
int processB(int argc, char **argv) {
  static int counter = 2;
  print("Scheduler process B is running\n");
  while (counter > 0) {
    print("Scheduler process B: row ");
    printNum(counter);
    printNewLine();
    sleep(1);
    counter--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<processB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <print@plt>
cmpl   $0x0,0x2ede(%rip)
jle    11a4 <processB+0x64>
lea    0xeb1(%rip),%rdi
call   1030 <print@plt>
mov    0x2ec6(%rip),%edi
call   1040 <printNum@plt>
mov    $0x0,%al
call   1050 <printNewLine@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    0x2eaa(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2ea1(%rip)
jmp    115b <processB+0x1b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processB>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1030 <print@plt>
cmpl   $0x0,0x2eec(%rip)
jle    1198 <processB+0x58>
lea    0xec3(%rip),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <print@plt>
mov    0x2ed2(%rip),%edi
call   1040 <printNum@plt>
xor    %eax,%eax
call   1050 <printNewLine@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    0x2eb6(%rip),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x2ead(%rip)
cmp    $0x1,%eax
jg     1160 <processB+0x20>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@processB.counter = internal global i32 2
@.str = [32 x i8] c"Scheduler process B is running\0A\00"
@.str.1 = [26 x i8] c"Scheduler process B: row \00"
define i32 @processB(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = call i32 @print(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %9, %2
%7 = load i32, i32* @processB.counter
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = call i32 @print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @processB.counter
%12 = call i32 @printNum(i32 %11)
%13 = call i32 (...) @printNewLine()
%14 = call i32 @sleep(i32 1)
%15 = load i32, i32* @processB.counter
%16 = add nsw i32 %15, -1
store i32 %16, i32* @processB.counter
br label %6
17: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@processB.counter = internal unnamed_addr global i32 2
@.str = [32 x i8] c"Scheduler process B is running\0A\00"
@.str.1 = [26 x i8] c"Scheduler process B: row \00"
define i32 @processB(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @print(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @processB.counter
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %2, %6
%7 = tail call i32 @print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @processB.counter
%9 = tail call i32 @printNum(i32 %8)
%10 = tail call i32 (...) @printNewLine()
%11 = tail call i32 @sleep(i32 1)
%12 = load i32, i32* @processB.counter
%13 = add nsw i32 %12, -1
store i32 %13, i32* @processB.counter
%14 = icmp sgt i32 %12, 1
br i1 %14, label %6, label %15
15: ; preds = %6, %2
ret i32 0
}