#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*/ StripComment(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
int test_charutil(void) {
  char *v = strdup("abc#def");
  StripComment(v);
  if (strcmp(v, "abc#def") != 0) {
    printf("FAILURE: comment stripper stripped when it shouldn't\n");
    return 1;
  }
  v = strdup("abc #def");
  StripComment(v);
  if (strcmp(v, "abc ") != 0) {
    printf("FAILURE: comment stripper should've stripped\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_charutil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <StripComment@plt>
mov    -0x10(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1193 <test_charutil+0x53>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <test_charutil+0xa5>
lea    0xea4(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <StripComment@plt>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11de <test_charutil+0x9e>
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <test_charutil+0xa5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_charutil>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%r14
mov    %r14,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <StripComment@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1177 <test_charutil+0x37>
lea    0xece(%rip),%rdi
jmp    11a9 <test_charutil+0x69>
lea    0xe8a(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <StripComment@plt>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11bb <test_charutil+0x7b>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    11b3 <test_charutil+0x73>

LLVM IR (-O0):
@.str = [8 x i8] c"abc#def\00"
@.str.1 = [54 x i8] c"FAILURE: comment stripper stripped when it shouldn't\0A\00"
@.str.2 = [9 x i8] c"abc #def\00"
@.str.3 = [5 x i8] c"abc \00"
@.str.4 = [46 x i8] c"FAILURE: comment stripper should've stripped\0A\00"
define i32 @test_charutil() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @StripComment(i8* %4)
%6 = load i8*, i8** %2
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %21
11: ; preds = %0
%12 = call i8* @strdup(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @StripComment(i8* %13)
%15 = load i8*, i8** %2
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %21
20: ; preds = %11
store i32 0, i32* %1
br label %21
21: ; preds = %20, %18, %9
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [8 x i8] c"abc#def\00"
@.str.2 = [9 x i8] c"abc #def\00"
@.str.3 = [5 x i8] c"abc \00"
@str = [45 x i8] c"FAILURE: comment stripper should've stripped\00"
@str.5 = [53 x i8] c"FAILURE: comment stripper stripped when it shouldn't\00"
define i32 @test_charutil() {
%1 = tail call dereferenceable_or_null(8) i8* @strdup(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @StripComment(i8* %1)
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = tail call dereferenceable_or_null(9) i8* @strdup(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @StripComment(i8* %6)
%8 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %5, %0
%11 = phi i8* [ getelementptr inbounds ([53 x i8], [53 x i8]* @str.5, i64 0, i64 0), %0 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0), %5 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %5
%14 = phi i32 [ 0, %5 ], [ 1, %10 ]
ret i32 %14
}