#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 */
scalar_t__ calloc(scalar_t__, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *strtok(char *, char *);
int getNameSpaceID(char *service, char *key) {
  char *temp;
  char *token;
  temp = (char *)calloc(strlen(key) + 1, sizeof(char));
  strcpy(temp, key);
  token = strtok(temp, ":");
  if (!strcmp(key, token))
    strcpy(service, "ipdr");
  else
    strcpy(service, token);
  free(temp);
  return (0);
}


x86 assembly (clang, -O0):
<getNameSpaceID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11da <getNameSpaceID+0x7a>
mov    -0x8(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcpy@plt>
jmp    11e7 <getNameSpaceID+0x87>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNameSpaceID>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcpy@plt>
lea    0xe67(%rip),%rsi
mov    %r15,%rdi
call   1080 <strtok@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
lea    0xe4a(%rip),%rsi
cmovne %rbx,%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [5 x i8] c"ipdr\00"
define i32 @getNameSpaceID(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 1
%10 = call i64 @calloc(i64 %9, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %5
%16 = call i8* @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %4
%18 = load i8*, i8** %6
%19 = call i32 @strcmp(i8* %17, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %2
%22 = load i8*, i8** %3
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %28
24: ; preds = %2
%25 = load i8*, i8** %3
%26 = load i8*, i8** %6
%27 = call i32 @strcpy(i8* %25, i8* %26)
br label %28
28: ; preds = %24, %21
%29 = load i8*, i8** %5
%30 = call i32 @free(i8* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [5 x i8] c"ipdr\00"
define i32 @getNameSpaceID(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = add nsw i64 %3, 1
%5 = tail call i64 @calloc(i64 %4, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i32 @strcpy(i8* %6, i8* %1)
%8 = tail call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(1) %8)
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %8
%12 = tail call i32 @strcpy(i8* %0, i8* %11)
%13 = tail call i32 @free(i8* %6)
ret i32 0
}