#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 */
scalar_t__ is_blank(char);
int /*<<< orphan*/ strcpyo(char *, char *);
int strlen(char *);
void cutcomment(char *text) {
  int laenge;
  while (is_blank(*text))
    strcpyo(text, text + 1);
  if (*text == '#')
    *text = 0;
  laenge = strlen(text);
  while (laenge > 0 &&
         ((unsigned char)text[laenge - 1] <= (unsigned char)' ')) {
    text[laenge - 1] = 0;
    laenge--;
  }
}


x86 assembly (clang, -O0):
<cutcomment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <is_blank@plt>
cmp    $0x0,%rax
je     1168 <cutcomment+0x38>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x1,%rsi
call   1040 <strcpyo@plt>
jmp    113c <cutcomment+0xc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    117f <cutcomment+0x4f>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jle    11b4 <cutcomment+0x84>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11c4 <cutcomment+0x94>
jmp    11e3 <cutcomment+0xb3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <cutcomment+0x5b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutcomment>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1050 <is_blank@plt>
test   %rax,%rax
je     1168 <cutcomment+0x38>
lea    0x1(%rbx),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpyo@plt>
movsbl (%rbx),%edi
call   1050 <is_blank@plt>
test   %rax,%rax
jne    1150 <cutcomment+0x20>
cmpb   $0x23,(%rbx)
jne    1170 <cutcomment+0x40>
movb   $0x0,(%rbx)
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a7 <cutcomment+0x77>
mov    %eax,%eax
add    $0x1,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x2(%rax),%ecx
cmpb   $0x20,(%rbx,%rcx,1)
ja     11a7 <cutcomment+0x77>
movb   $0x0,(%rbx,%rcx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     1190 <cutcomment+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cutcomment(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
br label %4
4: ; preds = %9, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = call i64 @is_blank(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = call i32 @strcpyo(i8* %10, i8* %12)
br label %4
14: ; preds = %4
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 35
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i8*, i8** %2
store i8 0, i8* %20
br label %21
21: ; preds = %19, %14
%22 = load i8*, i8** %2
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %3
br label %24
24: ; preds = %38, %21
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i8*, i8** %2
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = icmp sle i32 %34, 32
br label %36
36: ; preds = %27, %24
%37 = phi i1 [ false, %24 ], [ %35, %27 ]
br i1 %37, label %38, label %46
38: ; preds = %36
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
store i8 0, i8* %43
%44 = load i32, i32* %3
%45 = add nsw i32 %44, -1
store i32 %45, i32* %3
br label %24
46: ; preds = %36
ret void
}

LLVM IR (-O2):
define void @cutcomment(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @is_blank(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
br label %7
7: ; preds = %5, %7
%8 = tail call i32 @strcpyo(i8* %0, i8* %6)
%9 = load i8, i8* %0
%10 = tail call i64 @is_blank(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %7, %1
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 35
br i1 %14, label %15, label %16
15: ; preds = %12
store i8 0, i8* %0
br label %16
16: ; preds = %15, %12
%17 = tail call i32 @strlen(i8* %0)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %16
%20 = zext i32 %17 to i64
br label %21
21: ; preds = %19, %28
%22 = phi i64 [ %20, %19 ], [ %23, %28 ]
%23 = add nsw i64 %22, -1
%24 = and i64 %23, 4294967295
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp ult i8 %26, 33
br i1 %27, label %28, label %30
28: ; preds = %21
store i8 0, i8* %25
%29 = icmp ugt i64 %22, 1
br i1 %29, label %21, label %30
30: ; preds = %21, %28, %16
ret void
}