#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*/ isrunning();
scalar_t__ isstopped();
int /*<<< orphan*/ typestr(char *);
int /*<<< orphan*/ usleep(int);
void waitmemstop(void) {
  int i;
  if (!isrunning())
    return;
  for (i = 0; i < 20; i++) {
    if (isstopped())
      return;
    usleep(100);
  }
  typestr("not stopped!!!\r\n");
}


x86 assembly (clang, -O0):
<waitmemstop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <isrunning@plt>
cmp    $0x0,%eax
jne    115d <waitmemstop+0x1d>
jmp    11a8 <waitmemstop+0x68>
movl   $0x0,-0x4(%rbp)
cmpl   $0x14,-0x4(%rbp)
jge    119c <waitmemstop+0x5c>
mov    $0x0,%al
call   1030 <isstopped@plt>
cmp    $0x0,%rax
je     1184 <waitmemstop+0x44>
jmp    11a8 <waitmemstop+0x68>
mov    $0x64,%edi
call   1060 <usleep@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1164 <waitmemstop+0x24>
lea    0xe5d(%rip),%rdi
call   1050 <typestr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<waitmemstop>:
push   %rax
xor    %eax,%eax
call   1040 <isrunning@plt>
test   %eax,%eax
je     1336 <waitmemstop+0x1f6>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
jne    1336 <waitmemstop+0x1f6>
mov    $0x64,%edi
call   1060 <usleep@plt>
xor    %eax,%eax
call   1030 <isstopped@plt>
test   %rax,%rax
je     1338 <waitmemstop+0x1f8>
pop    %rax
ret
mov    $0x64,%edi
call   1060 <usleep@plt>
lea    0xcb7(%rip),%rdi
pop    %rax
jmp    1050 <typestr@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"not stopped!!!\0D\0A\00"
define void @waitmemstop() {
%1 = alloca i32
%2 = call i32 (...) @isrunning()
%3 = icmp ne i32 %2, 0
br i1 %3, label %5, label %4
4: ; preds = %0
br label %20
5: ; preds = %0
store i32 0, i32* %1
br label %6
6: ; preds = %15, %5
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = call i64 (...) @isstopped()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
br label %20
13: ; preds = %9
%14 = call i32 @usleep(i32 100)
br label %15
15: ; preds = %13
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %6
18: ; preds = %6
%19 = call i32 @typestr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %12, %4
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"not stopped!!!\0D\0A\00"
define void @waitmemstop() {
%1 = tail call i32 (...) @isrunning()
%2 = icmp eq i32 %1, 0
br i1 %2, label %85, label %3
3: ; preds = %0
%4 = tail call i64 (...) @isstopped()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %85
6: ; preds = %3
%7 = tail call i32 @usleep(i32 100)
%8 = tail call i64 (...) @isstopped()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %85
10: ; preds = %6
%11 = tail call i32 @usleep(i32 100)
%12 = tail call i64 (...) @isstopped()
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %85
14: ; preds = %10
%15 = tail call i32 @usleep(i32 100)
%16 = tail call i64 (...) @isstopped()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %85
18: ; preds = %14
%19 = tail call i32 @usleep(i32 100)
%20 = tail call i64 (...) @isstopped()
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %85
22: ; preds = %18
%23 = tail call i32 @usleep(i32 100)
%24 = tail call i64 (...) @isstopped()
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %85
26: ; preds = %22
%27 = tail call i32 @usleep(i32 100)
%28 = tail call i64 (...) @isstopped()
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %85
30: ; preds = %26
%31 = tail call i32 @usleep(i32 100)
%32 = tail call i64 (...) @isstopped()
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %85
34: ; preds = %30
%35 = tail call i32 @usleep(i32 100)
%36 = tail call i64 (...) @isstopped()
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %85
38: ; preds = %34
%39 = tail call i32 @usleep(i32 100)
%40 = tail call i64 (...) @isstopped()
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %85
42: ; preds = %38
%43 = tail call i32 @usleep(i32 100)
%44 = tail call i64 (...) @isstopped()
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %85
46: ; preds = %42
%47 = tail call i32 @usleep(i32 100)
%48 = tail call i64 (...) @isstopped()
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %85
50: ; preds = %46
%51 = tail call i32 @usleep(i32 100)
%52 = tail call i64 (...) @isstopped()
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %85
54: ; preds = %50
%55 = tail call i32 @usleep(i32 100)
%56 = tail call i64 (...) @isstopped()
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %85
58: ; preds = %54
%59 = tail call i32 @usleep(i32 100)
%60 = tail call i64 (...) @isstopped()
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %85
62: ; preds = %58
%63 = tail call i32 @usleep(i32 100)
%64 = tail call i64 (...) @isstopped()
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %85
66: ; preds = %62
%67 = tail call i32 @usleep(i32 100)
%68 = tail call i64 (...) @isstopped()
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %85
70: ; preds = %66
%71 = tail call i32 @usleep(i32 100)
%72 = tail call i64 (...) @isstopped()
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %85
74: ; preds = %70
%75 = tail call i32 @usleep(i32 100)
%76 = tail call i64 (...) @isstopped()
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %85
78: ; preds = %74
%79 = tail call i32 @usleep(i32 100)
%80 = tail call i64 (...) @isstopped()
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %78
%83 = tail call i32 @usleep(i32 100)
%84 = tail call i32 @typestr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %85
85: ; preds = %3, %6, %10, %14, %18, %22, %26, %30, %34, %38, %42, %46, %50, %54, %58, %62, %66, %70, %74, %78, %0, %82
ret void
}