#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*/ assert(int);
int read_command_char(char *parameter_value, char *command_char, int start) {
  int ch;
  int i;
  int j;
  int k;
  i = start;
  j = 0;
  k = 0;
  ch = parameter_value[i];
  while ((ch != '\0') && (ch != ';')) {
    command_char[j] = ch;
    j++;
    assert(j < 16);
    i++;
    assert(i < 256);
    ch = parameter_value[i];
  }
  command_char[j] = '\0';
  return ++i;
}


x86 assembly (clang, -O0):
<read_command_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x25(%rbp)
je     115f <read_command_char+0x4f>
cmpl   $0x3b,-0x18(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    116f <read_command_char+0x5f>
jmp    11ca <read_command_char+0xba>
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x10,-0x20(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <read_command_char+0x36>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_command_char>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r13
movslq %edx,%r12
add    %r12,%r13
xor    %eax,%eax
nopl   0x0(%rax)
movzbl 0x0(%r13,%rax,1),%ecx
test   %cl,%cl
je     1171 <read_command_char+0x61>
cmp    $0x3b,%cl
je     1171 <read_command_char+0x61>
lea    (%r12,%rax,1),%rbx
mov    %cl,(%r15,%rax,1)
lea    0x1(%rax),%rbp
xor    %edi,%edi
cmp    $0xf,%rax
setb   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0xff,%rbx
setl   %dil
call   1030 <assert@plt>
mov    %rbp,%rax
jmp    1130 <read_command_char+0x20>
mov    %eax,%ecx
movb   $0x0,(%r15,%rcx,1)
add    %r14d,%eax
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_command_char(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
store i32 %11, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = load i8*, i8** %4
%13 = load i32, i32* %8
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
store i32 %17, i32* %7
br label %18
18: ; preds = %26, %3
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 59
br label %24
24: ; preds = %21, %18
%25 = phi i1 [ false, %18 ], [ %23, %21 ]
br i1 %25, label %26, label %51
26: ; preds = %24
%27 = load i32, i32* %7
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = icmp slt i32 %35, 16
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = icmp slt i32 %41, 256
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i8*, i8** %4
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
store i32 %50, i32* %7
br label %18
51: ; preds = %24
%52 = load i8*, i8** %5
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 0, i8* %55
%56 = load i32, i32* %8
%57 = add nsw i32 %56, 1
store i32 %57, i32* %8
ret i32 %57
}

LLVM IR (-O2):
define i32 @read_command_char(i8* nocapture %0, i8* nocapture writeonly %1, i32 %2) {
%4 = sext i32 %2 to i64
br label %5
5: ; preds = %10, %3
%6 = phi i64 [ %12, %10 ], [ 0, %3 ]
%7 = phi i64 [ %16, %10 ], [ %4, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 59, label %20
i8 0, label %20
]
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 %9, i8* %11
%12 = add nuw i64 %6, 1
%13 = icmp ult i64 %6, 15
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = add i64 %7, 1
%17 = icmp slt i64 %7, 255
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
br label %5
20: ; preds = %5, %5
%21 = trunc i64 %7 to i32
%22 = and i64 %6, 4294967295
%23 = getelementptr inbounds i8, i8* %1, i64 %22
store i8 0, i8* %23
%24 = add nsw i32 %21, 1
ret i32 %24
}