#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 *my_strchr(char *, char);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char line[80] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin";
  char *line_ptr;
  line_ptr = line;
  while (line_ptr != NULL) {
    line_ptr = my_strchr(line_ptr, ':');
    if (line_ptr != NULL)
      *line_ptr = '\n';
  }
  printf("$PATH = %s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     1190 <main+0x60>
mov    -0x68(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <my_strchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     118b <main+0x5b>
mov    -0x68(%rbp),%rax
movb   $0xa,(%rax)
jmp    115c <main+0x2c>
lea    -0x60(%rbp),%rsi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
movaps 0xf15(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x3a,%esi
call   1040 <my_strchr@plt>
test   %rax,%rax
je     1187 <main+0x67>
movb   $0xa,(%rax)
mov    %rax,%rdi
jmp    1170 <main+0x50>
lea    0xec2(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@__const.main.line = [80 x i8] c"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [12 x i8] c"$PATH = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [80 x i8]* %2 to i8*
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
store i8* %5, i8** %3
br label %6
6: ; preds = %16, %0
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = call i8* @my_strchr(i8* %10, i8 signext 58)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = load i8*, i8** %3
store i8 10, i8* %15
br label %16
16: ; preds = %14, %9
br label %6
17: ; preds = %6
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.line = [80 x i8] c"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [12 x i8] c"$PATH = %s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = call i8* @my_strchr(i8* %2, i8 signext 58)
%4 = icmp eq i8* %3, null
br i1 %4, label %9, label %5
5: ; preds = %0, %5
%6 = phi i8* [ %7, %5 ], [ %3, %0 ]
store i8 10, i8* %6
%7 = call i8* @my_strchr(i8* %6, i8 signext 58)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %5
9: ; preds = %5, %0
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}