#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 *S_next_component(char **iter) {
  char *component = *iter;
  if (!component) {
    return NULL;
  }
  for (char *ptr = component; *ptr != '\0'; ptr++) {
    if (*ptr == '.') {
      *ptr = '\0';
      *iter = ptr + 1;
      return component;
    }
  }
  *iter = NULL;
  return component;
}


x86 assembly (clang, -O0):
<S_next_component>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    112b <S_next_component+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    119f <S_next_component+0x9f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118c <S_next_component+0x8c>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1176 <S_next_component+0x76>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <S_next_component+0x9f>
jmp    117b <S_next_component+0x7b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1133 <S_next_component+0x33>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_next_component>:
mov    (%rdi),%rax
test   %rax,%rax
je     112e <S_next_component+0x2e>
lea    0x1(%rax),%rcx
nopl   0x0(%rax)
movzbl -0x1(%rcx),%edx
test   %dl,%dl
je     1123 <S_next_component+0x23>
cmp    $0x2e,%dl
je     1127 <S_next_component+0x27>
add    $0x1,%rcx
jmp    1110 <S_next_component+0x10>
xor    %ecx,%ecx
jmp    112b <S_next_component+0x2b>
movb   $0x0,-0x1(%rcx)
mov    %rcx,(%rdi)
ret

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

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