#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 strlen(char *);
char *strip_comments(char *string) {
  const int length = strlen(string);
  if (length < 2) {
    return string;
  }
  for (int i = 0; i < length - 1; i++) {
    if (string[i] == '/' && string[i + 1] == '/') {
      string[i] = '\0';
      return string;
    }
  }
  return string;
}


x86 assembly (clang, -O0):
<strip_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    113f <strip_comments+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <strip_comments+0xaa>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b2 <strip_comments+0xa2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    119f <strip_comments+0x8f>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    119f <strip_comments+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <strip_comments+0xaa>
jmp    11a4 <strip_comments+0x94>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <strip_comments+0x36>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_comments>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     114a <strip_comments+0x3a>
add    $0xffffffff,%eax
xor    %ecx,%ecx
jmp    1139 <strip_comments+0x29>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rcx
cmp    %rcx,%rax
je     114a <strip_comments+0x3a>
cmpb   $0x2f,(%rbx,%rcx,1)
jne    1130 <strip_comments+0x20>
cmpb   $0x2f,0x1(%rbx,%rcx,1)
jne    1130 <strip_comments+0x20>
movb   $0x0,(%rbx,%rcx,1)
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @strip_comments(i8* returned %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = add nsw i32 %2, -1
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %4, %20
%8 = phi i64 [ 0, %4 ], [ %12, %20 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 47
%12 = add nuw nsw i64 %8, 1
br i1 %11, label %13, label %20
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = and i64 %8, 4294967295
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
br label %22
20: ; preds = %7, %13
%21 = icmp eq i64 %12, %6
br i1 %21, label %22, label %7
22: ; preds = %20, %17, %1
ret i8* %0
}