#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 get();
int getnb();
int /*<<< orphan*/ unget(int);
void getSid(char *id) {
  int c;
  char *p;
  c = getnb();
  p = id;
  do {
    if (p < &id[255 - 1])
      *p++ = c;
    c = get();
  } while (c != '\0' && c != ' ' && c != '\t');
  unget(c);
  *p++ = 0;
}


x86 assembly (clang, -O0):
<getSid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getnb@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0xfe,%rcx
cmp    %rcx,%rax
jae    117c <getSid+0x4c>
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    $0x0,%al
call   1040 <get@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x19(%rbp)
je     11ae <getSid+0x7e>
xor    %eax,%eax
cmpl   $0x20,-0xc(%rbp)
mov    %al,-0x19(%rbp)
je     11ae <getSid+0x7e>
cmpl   $0x9,-0xc(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    114e <getSid+0x1e>
mov    -0xc(%rbp),%edi
call   1030 <unget@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSid>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <getnb@plt>
movabs $0x100000201,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
cmp    $0xfd,%rbx
jg     1161 <getSid+0x31>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <get@plt>
cmp    $0x20,%eax
ja     1150 <getSid+0x20>
mov    %eax,%ecx
bt     %rcx,%r15
jae    1150 <getSid+0x20>
mov    %eax,%edi
call   1030 <unget@plt>
movb   $0x0,(%r14,%rbx,1)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @getSid(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 (...) @getnb()
store i32 %5, i32* %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %28, %1
%8 = load i8*, i8** %4
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 254
%11 = icmp ult i8* %8, %10
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = load i32, i32* %3
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
store i8 %14, i8* %15
br label %17
17: ; preds = %12, %7
%18 = call i32 (...) @get()
store i32 %18, i32* %3
br label %19
19: ; preds = %17
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 32
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 9
br label %28
28: ; preds = %25, %22, %19
%29 = phi i1 [ false, %22 ], [ false, %19 ], [ %27, %25 ]
br i1 %29, label %7, label %30
30: ; preds = %28
%31 = load i32, i32* %3
%32 = call i32 @unget(i32 %31)
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
store i8 0, i8* %33
ret void
}

LLVM IR (-O2):
define void @getSid(i8* nocapture writeonly %0) {
%2 = tail call i32 (...) @getnb()
br label %3
3: ; preds = %11, %1
%4 = phi i32 [ %2, %1 ], [ %13, %11 ]
%5 = phi i64 [ 0, %1 ], [ %12, %11 ]
%6 = icmp slt i64 %5, 254
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 %5
%9 = trunc i32 %4 to i8
%10 = add nsw i64 %5, 1
store i8 %9, i8* %8
br label %11
11: ; preds = %7, %3
%12 = phi i64 [ %10, %7 ], [ %5, %3 ]
%13 = tail call i32 (...) @get()
switch i32 %13, label %3 [
i32 32, label %14
i32 9, label %14
i32 0, label %14
]
14: ; preds = %11, %11, %11
%15 = getelementptr inbounds i8, i8* %0, i64 %12
%16 = tail call i32 @unget(i32 %13)
store i8 0, i8* %15
ret void
}