#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*/ ems1Stok(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void emsSetnc(const char *token, const char *cvalue, int maxchar) {
  int vallen;
  int i;
  char valbuf[200 + 1];
  ;
  ;
  vallen = maxchar > 200 ? 200 : maxchar;
  strncpy(valbuf, cvalue, vallen);
  valbuf[vallen] = '\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):
<emsSetnc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jle    1173 <emsSetnc+0x33>
mov    $0xc8,%eax
mov    %eax,-0xf4(%rbp)
jmp    117c <emsSetnc+0x3c>
mov    -0x14(%rbp),%eax
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    -0xf0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    11ee <emsSetnc+0xae>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xf0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     11db <emsSetnc+0x9b>
jmp    11ee <emsSetnc+0xae>
jmp    11e0 <emsSetnc+0xa0>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b3 <emsSetnc+0x73>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0xf0(%rbp,%rax,1)
cmpl   $0x0,-0x1c(%rbp)
jne    1217 <emsSetnc+0xd7>
lea    -0xf0(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1060 <ems1Stok@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emsSetnc>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rdi,%r14
cmp    $0xc8,%edx
mov    $0xc8,%ebp
cmovl  %edx,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
cltq
add    %rsp,%rax
nop
test   %ecx,%ecx
jle    119d <emsSetnc+0x5d>
lea    -0x1(%rcx),%rdx
add    $0xffffffffffffffff,%rax
cmpb   $0x20,-0x1(%rsp,%rcx,1)
mov    %rdx,%rcx
je     1180 <emsSetnc+0x40>
movb   $0x0,0x1(%rsp,%rdx,1)
jmp    11b3 <emsSetnc+0x73>
movb   $0x0,(%rax)
test   %ecx,%ecx
jne    11b3 <emsSetnc+0x73>
lea    0xe55(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strcpy@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <ems1Stok@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @emsSetnc(i8* %0, i8* %1, i32 %2) {
%4 = alloca [201 x i8]
%5 = getelementptr inbounds [201 x i8], [201 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %2, 200
%7 = select i1 %6, i32 %2, i32 200
%8 = call i32 @strncpy(i8* %5, i8* %1, i32 %7)
%9 = sext i32 %7 to i64
%10 = getelementptr inbounds [201 x i8], [201 x i8]* %4, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 @strlen(i8* %5)
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %17, %3
%14 = phi i64 [ %18, %17 ], [ %12, %3 ]
%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 [201 x i8], [201 x i8]* %4, 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 [201 x i8], [201 x i8]* %4, 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 [201 x i8], [201 x i8]* %4, 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
}