#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 *get_sensor_type_desc(unsigned char);
int strlen_(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *get_stype_str(unsigned char stype) {
  static char stype_str[15 + 1];
  char *tmpstr;
  int i, n;
  tmpstr = get_sensor_type_desc(stype);
  n = strlen_(tmpstr);
  if (n > 15)
    n = 15;
  strncpy(stype_str, tmpstr, n);
  for (i = n; i < 15; i++)
    stype_str[i] = ' ';
  stype_str[i] = 0;
  tmpstr = stype_str;
  return (tmpstr);
}


x86 assembly (clang, -O0):
<get_stype_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <get_sensor_type_desc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen_@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xf,-0x18(%rbp)
jle    1168 <get_stype_str+0x38>
movl   $0xf,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
lea    0x2eda(%rip),%rdi
call   1040 <strncpy@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xf,-0x14(%rbp)
jge    11a8 <get_stype_str+0x78>
movslq -0x14(%rbp),%rcx
lea    0x2eba(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1181 <get_stype_str+0x51>
movslq -0x14(%rbp),%rcx
lea    0x2e9d(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e92(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_stype_str>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
call   1030 <get_sensor_type_desc@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1060 <strlen_@plt>
mov    %eax,%ebx
cmp    $0xf,%eax
mov    $0xf,%ebp
cmovl  %eax,%ebp
lea    0x2ee5(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
cmp    $0xe,%ebx
jg     119b <get_stype_str+0x5b>
movslq %ebp,%rax
add    %rax,%r14
mov    $0xe,%edx
sub    %ebp,%edx
add    $0x1,%rdx
mov    %r14,%rdi
mov    $0x20,%esi
call   1050 <memset@plt>
movb   $0x0,0x2ebd(%rip)
lea    0x2ea7(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_stype_str.stype_str = internal global [16 x i8] zeroinitializer
define i8* @get_stype_str(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %2
%6 = load i8, i8* %2
%7 = call i8* @get_sensor_type_desc(i8 zeroext %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen_(i8* %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 15
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 15, i32* %5
br label %13
13: ; preds = %12, %1
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = call i32 @strncpy(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i32, i32* %5
store i32 %17, i32* %4
br label %18
18: ; preds = %25, %13
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 15
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 %23
store i8 32, i8* %24
br label %25
25: ; preds = %21
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %18
28: ; preds = %18
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 %30
store i8 0, i8* %31
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 0), i8** %3
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
@get_stype_str.stype_str = internal global [16 x i8] zeroinitializer
define i8* @get_stype_str(i8 zeroext %0) {
%2 = tail call i8* @get_sensor_type_desc(i8 zeroext %0)
%3 = tail call i32 @strlen_(i8* %2)
%4 = icmp slt i32 %3, 15
%5 = select i1 %4, i32 %3, i32 15
%6 = tail call i32 @strncpy(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 0), i8* %2, i32 %5)
br i1 %4, label %7, label %13
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = getelementptr [16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 %8
%10 = sub i32 14, %5
%11 = zext i32 %10 to i64
%12 = add nuw nsw i64 %11, 1
br label %13
13: ; preds = %7, %1
store i8 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 15)
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @get_stype_str.stype_str, i64 0, i64 0)
}