#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 */
char *malloc(size_t);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
char *dotless_copy(const char *s) {
  size_t i;
  char *copy;
  i = 0;
  while (s[i] != '\0' && s[i] != '.')
    i++;
  copy = malloc((i + 1) * sizeof(char));
  if (copy != NULL) {
    strncpy(copy, s, i);
    copy[i] = '\0';
  }
  return copy;
}


x86 assembly (clang, -O0):
<dotless_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1163 <dotless_copy+0x43>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1173 <dotless_copy+0x53>
jmp    1184 <dotless_copy+0x64>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <dotless_copy+0x14>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
shl    $0x0,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c1 <dotless_copy+0xa1>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dotless_copy>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%eax
test   %al,%al
je     1143 <dotless_copy+0x23>
cmp    $0x2e,%al
je     1143 <dotless_copy+0x23>
add    $0x1,%rbx
jmp    1130 <dotless_copy+0x10>
lea    0x1(%rbx),%rdi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     1167 <dotless_copy+0x47>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
movb   $0x0,(%r15,%rbx,1)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @dotless_copy(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* %3
br label %5
5: ; preds = %21, %1
%6 = load i8*, i8** %2
%7 = load i64, i64* %3
%8 = getelementptr inbounds i8, i8* %6, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %5
%13 = load i8*, i8** %2
%14 = load i64, i64* %3
%15 = getelementptr inbounds i8, i8* %13, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 46
br label %19
19: ; preds = %12, %5
%20 = phi i1 [ false, %5 ], [ %18, %12 ]
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i64, i64* %3
%23 = add i64 %22, 1
store i64 %23, i64* %3
br label %5
24: ; preds = %19
%25 = load i64, i64* %3
%26 = add i64 %25, 1
%27 = mul i64 %26, 1
%28 = call i8* @malloc(i64 %27)
store i8* %28, i8** %4
%29 = load i8*, i8** %4
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %39
31: ; preds = %24
%32 = load i8*, i8** %4
%33 = load i8*, i8** %2
%34 = load i64, i64* %3
%35 = call i32 @strncpy(i8* %32, i8* %33, i64 %34)
%36 = load i8*, i8** %4
%37 = load i64, i64* %3
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8 0, i8* %38
br label %39
39: ; preds = %31, %24
%40 = load i8*, i8** %4
ret i8* %40
}

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