#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*/ eeputs(int);
int findend(int);
int findoccupied(int);
int /*<<< orphan*/ msgp(int);
int /*<<< orphan*/ spb(char);
int /*<<< orphan*/ speol();
void cmd_ls(void) {
  int start = 0;
  for (;;) {
    start = findoccupied(start);
    if (start == ((int)-1))
      return;
    msgp(28);
    spb(' ');
    eeputs(start);
    spb(' ');
    spb('{');
    start = findend(start);
    eeputs(start);
    spb('}');
    spb(';');
    speol();
    start = findend(start);
  }
}


x86 assembly (clang, -O0):
<cmd_ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <findoccupied@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    118a <cmd_ls+0x2a>
add    $0x10,%rsp
pop    %rbp
ret
mov    $0x1c,%edi
call   1070 <msgp@plt>
mov    $0x20,%edi
call   1050 <spb@plt>
mov    -0x4(%rbp),%edi
call   1060 <eeputs@plt>
mov    $0x20,%edi
call   1050 <spb@plt>
mov    $0x7b,%edi
call   1050 <spb@plt>
mov    -0x4(%rbp),%edi
call   1080 <findend@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <eeputs@plt>
mov    $0x7d,%edi
call   1050 <spb@plt>
mov    $0x3b,%edi
call   1050 <spb@plt>
mov    $0x0,%al
call   1040 <speol@plt>
mov    -0x4(%rbp),%edi
call   1080 <findend@plt>
mov    %eax,-0x4(%rbp)
jmp    116f <cmd_ls+0xf>

x86 assembly (clang, -O2):
<cmd_ls>:
push   %rbx
xor    %edi,%edi
call   1030 <findoccupied@plt>
cmp    $0xffffffff,%eax
je     11df <cmd_ls+0x7f>
mov    %eax,%ebx
nop
mov    $0x1c,%edi
call   1070 <msgp@plt>
mov    $0x20,%edi
call   1050 <spb@plt>
mov    %ebx,%edi
call   1060 <eeputs@plt>
mov    $0x20,%edi
call   1050 <spb@plt>
mov    $0x7b,%edi
call   1050 <spb@plt>
mov    %ebx,%edi
call   1080 <findend@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <eeputs@plt>
mov    $0x7d,%edi
call   1050 <spb@plt>
mov    $0x3b,%edi
call   1050 <spb@plt>
xor    %eax,%eax
call   1040 <speol@plt>
mov    %ebx,%edi
call   1080 <findend@plt>
mov    %eax,%edi
call   1030 <findoccupied@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1170 <cmd_ls+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @cmd_ls() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %8, %0
%3 = load i32, i32* %1
%4 = call i32 @findoccupied(i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %8
7: ; preds = %2
ret void
8: ; preds = %2
%9 = call i32 @msgp(i32 28)
%10 = call i32 @spb(i8 signext 32)
%11 = load i32, i32* %1
%12 = call i32 @eeputs(i32 %11)
%13 = call i32 @spb(i8 signext 32)
%14 = call i32 @spb(i8 signext 123)
%15 = load i32, i32* %1
%16 = call i32 @findend(i32 %15)
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = call i32 @eeputs(i32 %17)
%19 = call i32 @spb(i8 signext 125)
%20 = call i32 @spb(i8 signext 59)
%21 = call i32 (...) @speol()
%22 = load i32, i32* %1
%23 = call i32 @findend(i32 %22)
store i32 %23, i32* %1
br label %2
}

LLVM IR (-O2):
define void @cmd_ls() {
%1 = tail call i32 @findoccupied(i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %4
3: ; preds = %4, %0
ret void
4: ; preds = %0, %4
%5 = phi i32 [ %17, %4 ], [ %1, %0 ]
%6 = tail call i32 @msgp(i32 28)
%7 = tail call i32 @spb(i8 signext 32)
%8 = tail call i32 @eeputs(i32 %5)
%9 = tail call i32 @spb(i8 signext 32)
%10 = tail call i32 @spb(i8 signext 123)
%11 = tail call i32 @findend(i32 %5)
%12 = tail call i32 @eeputs(i32 %11)
%13 = tail call i32 @spb(i8 signext 125)
%14 = tail call i32 @spb(i8 signext 59)
%15 = tail call i32 (...) @speol()
%16 = tail call i32 @findend(i32 %11)
%17 = tail call i32 @findoccupied(i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %3, label %4
}