#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
char *strchr(char const *, char);
int /*<<< orphan*/ strncpy(char *, char const *, int);
const char *project_of(const char *id) {
  static char project_buf[128];
  char *colon = strchr(id, ':');
  if (colon - id < 128) {
    strncpy(project_buf, id, colon - id);
    project_buf[colon - id] = '\0';
  } else {
    fprintf(stderr, "wm: project too long (%s)", id);
    exit(1);
  }
  return project_buf;
}


x86 assembly (clang, -O0):
<project_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x80,%rax
jge    11ad <project_of+0x6d>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
lea    0x2ec3(%rip),%rdi
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rax,%rcx
lea    0x2eac(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    11d0 <project_of+0x90>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe3f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0x2e79(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<project_of>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
sub    %r14,%rbx
cmp    $0x7f,%rbx
jg     1180 <project_of+0x40>
lea    0x2eeb(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%rbx,%r15,1)
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@project_of.project_buf = internal global [128 x i8] zeroinitializer
@stderr = global i32 0
@.str = [26 x i8] c"wm: project too long (%s)\00"
define i8* @project_of(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strchr(i8* %4, i8 signext 58)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %2
%8 = ptrtoint i8* %6 to i64
%9 = ptrtoint i8* %7 to i64
%10 = sub i64 %8, %9
%11 = icmp slt i64 %10, 128
br i1 %11, label %12, label %27
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = load i8*, i8** %3
%15 = load i8*, i8** %2
%16 = ptrtoint i8* %14 to i64
%17 = ptrtoint i8* %15 to i64
%18 = sub i64 %16, %17
%19 = trunc i64 %18 to i32
%20 = call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 0), i8* %13, i32 %19)
%21 = load i8*, i8** %3
%22 = load i8*, i8** %2
%23 = ptrtoint i8* %21 to i64
%24 = ptrtoint i8* %22 to i64
%25 = sub i64 %23, %24
%26 = getelementptr inbounds [128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 %25
store i8 0, i8* %26
br label %32
27: ; preds = %1
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %2
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %12
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 0)
}

LLVM IR (-O2):
@project_of.project_buf = internal global [128 x i8] zeroinitializer
@stderr = global i32 0
@.str = [26 x i8] c"wm: project too long (%s)\00"
define i8* @project_of(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%3 = ptrtoint i8* %2 to i64
%4 = ptrtoint i8* %0 to i64
%5 = sub i64 %3, %4
%6 = icmp slt i64 %5, 128
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = trunc i64 %5 to i32
%9 = tail call i32 @strncpy(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 0), i8* %0, i32 %8)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 %5
store i8 0, i8* %10
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @project_of.project_buf, i64 0, i64 0)
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%14 = tail call i32 @exit(i32 1)
unreachable
}