#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 */
typedef int /*<<< orphan*/ valbuf;

/* Variables and functions */
int /*<<< orphan*/ ems1Stok(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void emsSetc(const char *token, const char *cvalue) {
  int i;
  char valbuf[200 + 2];
  const char null[] = "<Null>";
  ;
  ;
  valbuf[0] = '\0';
  if (cvalue) {
    strncpy(valbuf, cvalue, sizeof(valbuf));
  } else {
    strncpy(valbuf, null, sizeof(valbuf));
  }
  valbuf[sizeof(valbuf) - 1] = '\0';
  for (i = strlen(valbuf); i > 0; i--) {
    if (valbuf[i - 1] != ' ')
      break;
  }
  valbuf[i] = '\0';
  if (!i) {
    strcpy(valbuf, " ");
  }
  ems1Stok(token, valbuf);
  return;
}


x86 assembly (clang, -O0):
<emsSetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea7(%rip),%eax
mov    %eax,-0xe7(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0xe3(%rbp)
mov    0xe93(%rip),%al
mov    %al,-0xe1(%rbp)
movb   $0x0,-0xe0(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a5 <emsSetc+0x65>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0xca,%edx
call   1030 <strncpy@plt>
jmp    11bd <emsSetc+0x7d>
lea    -0xe0(%rbp),%rdi
lea    -0xe7(%rbp),%rsi
mov    $0xca,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x17(%rbp)
lea    -0xe0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    120b <emsSetc+0xcb>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xe0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     11f8 <emsSetc+0xb8>
jmp    120b <emsSetc+0xcb>
jmp    11fd <emsSetc+0xbd>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11d0 <emsSetc+0x90>
movslq -0x14(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
cmpl   $0x0,-0x14(%rbp)
jne    1234 <emsSetc+0xf4>
lea    -0xe0(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <ems1Stok@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emsSetc>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
mov    %rdi,%r14
movl   $0x3e6c6c,0xb(%rsp)
movl   $0x6c754e3c,0x8(%rsp)
6c
movb   $0x0,0x10(%rsp)
test   %rsi,%rsi
lea    0x8(%rsp),%rax
cmove  %rax,%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xca,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xd9(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
cltq
add    %rsp,%rax
add    $0x10,%rax
nopl   0x0(%rax,%rax,1)
test   %ecx,%ecx
jle    11bd <emsSetc+0x7d>
lea    -0x1(%rcx),%rdx
add    $0xffffffffffffffff,%rax
cmpb   $0x20,0xf(%rsp,%rcx,1)
mov    %rdx,%rcx
je     11a0 <emsSetc+0x60>
movb   $0x0,0x11(%rsp,%rdx,1)
jmp    11d5 <emsSetc+0x95>
movb   $0x0,(%rax)
test   %ecx,%ecx
jne    11d5 <emsSetc+0x95>
lea    0xe3c(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1040 <strcpy@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1060 <ems1Stok@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.emsSetc.null = [7 x i8] c"<Null>\00"
@.str = [2 x i8] c" \00"
define void @emsSetc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [202 x i8]
%7 = alloca [7 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = bitcast [7 x i8]* %7 to i8*
%9 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
store i8 0, i8* %9
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%14 = load i8*, i8** %4
%15 = call i32 @strncpy(i8* %13, i8* %14, i32 202)
br label %20
16: ; preds = %2
%17 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [7 x i8], [7 x i8]* %7, i64 0, i64 0
%19 = call i32 @strncpy(i8* %17, i8* %18, i32 202)
br label %20
20: ; preds = %16, %12
%21 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 201
store i8 0, i8* %21
%22 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %5
br label %24
24: ; preds = %37, %20
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 32
br i1 %34, label %35, label %36
35: ; preds = %27
br label %40
36: ; preds = %27
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, -1
store i32 %39, i32* %5
br label %24
40: ; preds = %35, %24
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 %42
store i8 0, i8* %43
%44 = load i32, i32* %5
%45 = icmp ne i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %40
%47 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%48 = call i32 @strcpy(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %46, %40
%50 = load i8*, i8** %3
%51 = getelementptr inbounds [202 x i8], [202 x i8]* %6, i64 0, i64 0
%52 = call i32 @ems1Stok(i8* %50, i8* %51)
ret void
}

LLVM IR (-O2):
@__const.emsSetc.null = [7 x i8] c"<Null>\00"
@.str = [2 x i8] c" \00"
define void @emsSetc(i8* %0, i8* %1) {
%3 = alloca [202 x i8]
%4 = alloca [7 x i8]
%5 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
store i8 0, i8* %5
%7 = icmp eq i8* %1, null
%8 = select i1 %7, i8* %6, i8* %1
%9 = call i32 @strncpy(i8* %5, i8* %8, i32 202)
%10 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 201
store i8 0, i8* %10
%11 = call i32 @strlen(i8* %5)
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %17, %2
%14 = phi i64 [ %18, %17 ], [ %12, %2 ]
%15 = trunc i64 %14 to i32
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = add nsw i64 %14, -1
%19 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 32
br i1 %21, label %13, label %22
22: ; preds = %17
%23 = and i64 %14, 4294967295
%24 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %23
store i8 0, i8* %24
br label %33
25: ; preds = %13
%26 = trunc i64 %14 to i32
%27 = shl i64 %14, 32
%28 = ashr exact i64 %27, 32
%29 = getelementptr inbounds [202 x i8], [202 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = icmp eq i32 %26, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %22, %31, %25
%34 = call i32 @ems1Stok(i8* %0, i8* %5)
ret void
}