#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*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strchr(char *, char);
char *gettype(char *buffer, char *typ) {
  if (!typ || !*typ || (typ[0] == '.' && typ[1] == 0))
    typ = "_http._tcp";
  if (!strchr(typ, '.')) {
    snprintf(buffer, 80, "%s._tcp", typ);
    typ = buffer;
  }
  return (typ);
}


x86 assembly (clang, -O0):
<gettype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1169 <gettype+0x49>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1169 <gettype+0x49>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1174 <gettype+0x54>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1174 <gettype+0x54>
lea    0xe90(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    11ac <gettype+0x8c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x50,%esi
lea    0xe6c(%rip),%rdx
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gettype>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     113f <gettype+0x1f>
mov    %rsi,%rbx
mov    (%rsi),%al
test   %al,%al
je     113f <gettype+0x1f>
cmp    $0x2e,%al
jne    1146 <gettype+0x26>
cmpb   $0x0,0x1(%rbx)
jne    1146 <gettype+0x26>
lea    0xeba(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %eax,%eax
je     115c <gettype+0x3c>
mov    %rbx,%r14
jmp    1173 <gettype+0x53>
lea    0xea8(%rip),%rdx
mov    %r14,%rdi
mov    $0x50,%esi
mov    %rbx,%rcx
call   1040 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"_http._tcp\00"
@.str.1 = [8 x i8] c"%s._tcp\00"
define i8* @gettype(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %23
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 46
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17, %7, %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %4
br label %24
24: ; preds = %23, %17, %11
%25 = load i8*, i8** %4
%26 = call i32 @strchr(i8* %25, i8 signext 46)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = load i8*, i8** %4
%31 = call i32 @snprintf(i8* %29, i32 80, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %3
store i8* %32, i8** %4
br label %33
33: ; preds = %28, %24
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
@.str = [11 x i8] c"_http._tcp\00"
@.str.1 = [8 x i8] c"%s._tcp\00"
define i8* @gettype(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i8, i8* %1
switch i8 %5, label %11 [
i8 0, label %10
i8 46, label %6
]
6: ; preds = %4
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %4, %6, %2
br label %11
11: ; preds = %4, %10, %6
%12 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %10 ], [ %1, %6 ], [ %1, %4 ]
%13 = tail call i32 @strchr(i8* %12, i8 signext 46)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @snprintf(i8* %0, i32 80, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %17
17: ; preds = %15, %11
%18 = phi i8* [ %12, %11 ], [ %0, %15 ]
ret i8* %18
}