#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*/ assert(int /*<<< orphan*/);
void chop_extension(char *string) {
  assert(string != NULL);
  char *last_point = NULL;
  while (*string != 0) {
    if (*string == '.') {
      last_point = string;
    }
    string += 1;
  }
  if (last_point != NULL) {
    *last_point = 0;
  }
}


x86 assembly (clang, -O0):
<chop_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116f <chop_extension+0x5f>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    115e <chop_extension+0x4e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1136 <chop_extension+0x26>
cmpq   $0x0,-0x10(%rbp)
je     1181 <chop_extension+0x71>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chop_extension>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %eax,%eax
jmp    1137 <chop_extension+0x27>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rax
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x2e,%cl
je     1130 <chop_extension+0x20>
test   %cl,%cl
jne    1133 <chop_extension+0x23>
test   %rax,%rax
je     114b <chop_extension+0x3b>
movb   $0x0,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define void @chop_extension(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
store i8* null, i8** %3
br label %8
8: ; preds = %20, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 46
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i8*, i8** %2
store i8* %19, i8** %3
br label %20
20: ; preds = %18, %13
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %2
br label %8
23: ; preds = %8
%24 = load i8*, i8** %3
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i8*, i8** %3
store i8 0, i8* %27
br label %28
28: ; preds = %26, %23
ret void
}

LLVM IR (-O2):
define void @chop_extension(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
br label %5
5: ; preds = %10, %1
%6 = phi i8* [ %0, %1 ], [ %12, %10 ]
%7 = phi i8* [ null, %1 ], [ %11, %10 ]
%8 = load i8, i8* %6
switch i8 %8, label %10 [
i8 0, label %13
i8 46, label %9
]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i8* [ %6, %9 ], [ %7, %5 ]
%12 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
13: ; preds = %5
%14 = icmp eq i8* %7, null
br i1 %14, label %16, label %15
15: ; preds = %13
store i8 0, i8* %7
br label %16
16: ; preds = %15, %13
ret void
}