#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 */
typedef int /*<<< orphan*/ curr_file_name;

/* Variables and functions */
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *const, size_t);
char *strtok(char *, char *);
void get_led_info(const char *const filename, char *device_name_out,
                  size_t device_name_out_size, char *color_out,
                  size_t color_out_size, char *function_out,
                  size_t function_out_size) {
  char curr_file_name[255];
  char *first_tok, *second_tok, *third_tok;
  char *device_name, *color, *function;
  strncpy(curr_file_name, filename, sizeof(curr_file_name));
  first_tok = strtok(curr_file_name, ":");
  second_tok = strtok(NULL, ":");
  third_tok = strtok(NULL, ":");
  if (first_tok != curr_file_name) {
    if (first_tok > curr_file_name + 1) {
      device_name = NULL;
      color = NULL;
      function = first_tok;
    } else {
      device_name = NULL;
      color = first_tok;
      function = second_tok;
    }
  } else if (second_tok > curr_file_name + strlen(first_tok) + 1) {
    device_name = first_tok;
    color = NULL;
    function = second_tok;
  } else {
    device_name = first_tok;
    color = second_tok;
    function = third_tok;
  }
  do {
    if (device_name_out != NULL && device_name_out_size > 0) {
      if (device_name != NULL) {
        strncpy(device_name_out, device_name, device_name_out_size);
      } else {
        device_name_out[0] = '\0';
      }
    }
  } while (0);
  do {
    if (color_out != NULL && color_out_size > 0) {
      if (color != NULL) {
        strncpy(color_out, color, color_out_size);
      } else {
        color_out[0] = '\0';
      }
    }
  } while (0);
  do {
    if (function_out != NULL && function_out_size > 0) {
      if (function != NULL) {
        strncpy(function_out, function, function_out_size);
      } else {
        function_out[0] = '\0';
      }
    }
  } while (0);
}


x86 assembly (clang, -O0):
<get_led_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
lea    -0x130(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x138(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6f(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x140(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe58(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x148(%rbp)
mov    -0x138(%rbp),%rax
lea    -0x130(%rbp),%rcx
cmp    %rcx,%rax
je     123b <get_led_info+0x10b>
mov    -0x138(%rbp),%rax
lea    -0x130(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jbe    120f <get_led_info+0xdf>
movq   $0x0,-0x150(%rbp)
movq   $0x0,-0x158(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,-0x160(%rbp)
jmp    1236 <get_led_info+0x106>
movq   $0x0,-0x150(%rbp)
mov    -0x138(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x160(%rbp)
jmp    12e1 <get_led_info+0x1b1>
mov    -0x140(%rbp),%rax
mov    %rax,-0x168(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x138(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x170(%rbp),%rcx
mov    %eax,%edx
mov    -0x168(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jbe    12b2 <get_led_info+0x182>
mov    -0x138(%rbp),%rax
mov    %rax,-0x150(%rbp)
movq   $0x0,-0x158(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x160(%rbp)
jmp    12dc <get_led_info+0x1ac>
mov    -0x138(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    -0x140(%rbp),%rax
mov    %rax,-0x158(%rbp)
mov    -0x148(%rbp),%rax
mov    %rax,-0x160(%rbp)
jmp    12e1 <get_led_info+0x1b1>
jmp    12e6 <get_led_info+0x1b6>
cmpq   $0x0,-0x10(%rbp)
je     132f <get_led_info+0x1ff>
cmpq   $0x0,-0x18(%rbp)
jbe    132f <get_led_info+0x1ff>
cmpq   $0x0,-0x150(%rbp)
je     1323 <get_led_info+0x1f3>
mov    -0x10(%rbp),%rdi
mov    -0x150(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
jmp    132a <get_led_info+0x1fa>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    132f <get_led_info+0x1ff>
jmp    1334 <get_led_info+0x204>
jmp    1339 <get_led_info+0x209>
cmpq   $0x0,-0x20(%rbp)
je     1382 <get_led_info+0x252>
cmpq   $0x0,-0x28(%rbp)
jbe    1382 <get_led_info+0x252>
cmpq   $0x0,-0x158(%rbp)
je     1376 <get_led_info+0x246>
mov    -0x20(%rbp),%rdi
mov    -0x158(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncpy@plt>
jmp    137d <get_led_info+0x24d>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1382 <get_led_info+0x252>
jmp    1387 <get_led_info+0x257>
jmp    138c <get_led_info+0x25c>
cmpq   $0x0,-0x30(%rbp)
je     13d5 <get_led_info+0x2a5>
cmpq   $0x0,0x10(%rbp)
jbe    13d5 <get_led_info+0x2a5>
cmpq   $0x0,-0x160(%rbp)
je     13c9 <get_led_info+0x299>
mov    -0x30(%rbp),%rdi
mov    -0x160(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   1030 <strncpy@plt>
jmp    13d0 <get_led_info+0x2a0>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
jmp    13d5 <get_led_info+0x2a5>
jmp    13da <get_led_info+0x2aa>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_led_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,%r13
mov    %rdi,%rsi
lea    0x20(%rsp),%r14
mov    $0xff,%edx
mov    %r14,%rdi
call   1030 <strncpy@plt>
lea    0xe8d(%rip),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <strtok@plt>
mov    %rax,%r12
xor    %edi,%edi
mov    %rbp,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %rbp,%rsi
call   1050 <strtok@plt>
cmp    %r14,%r12
je     120e <get_led_info+0xde>
lea    0x21(%rsp),%rax
xor    %r14d,%r14d
cmp    %rax,%r12
cmovbe %r12,%r14
cmova  %r12,%rbx
test   %r13,%r13
je     11c2 <get_led_info+0x92>
cmpq   $0x0,0x18(%rsp)
je     11c2 <get_led_info+0x92>
movb   $0x0,0x0(%r13)
mov    %rbx,%r15
mov    0x10(%rsp),%rbx
mov    0x8(%rsp),%rdx
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11ea <get_led_info+0xba>
test   %rdx,%rdx
je     11ea <get_led_info+0xba>
test   %r14,%r14
je     1258 <get_led_info+0x128>
mov    %r14,%rsi
call   1030 <strncpy@plt>
test   %rbx,%rbx
je     1265 <get_led_info+0x135>
mov    0x160(%rsp),%rdx
test   %rdx,%rdx
je     1265 <get_led_info+0x135>
test   %r15,%r15
je     1262 <get_led_info+0x132>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strncpy@plt>
jmp    1265 <get_led_info+0x135>
mov    %rax,%r15
lea    0x20(%rsp),%rdi
call   1040 <strlen@plt>
cltq
add    %rsp,%rax
add    $0x21,%rax
xor    %r14d,%r14d
cmp    %rax,%rbx
cmovbe %rbx,%r14
cmova  %rbx,%r15
test   %r13,%r13
je     11c5 <get_led_info+0x95>
mov    0x18(%rsp),%rdx
test   %rdx,%rdx
mov    0x10(%rsp),%rbx
je     11ca <get_led_info+0x9a>
lea    0x20(%rsp),%rsi
mov    %r13,%rdi
call   1030 <strncpy@plt>
jmp    11ca <get_led_info+0x9a>
movb   $0x0,(%rdi)
test   %rbx,%rbx
jne    11ef <get_led_info+0xbf>
jmp    1265 <get_led_info+0x135>
movb   $0x0,(%rbx)
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define void @get_led_info(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4, i8* %5, i64 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca [255 x i8]
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
store i8* %0, i8** %8
store i8* %1, i8** %9
store i64 %2, i64* %10
store i8* %3, i8** %11
store i64 %4, i64* %12
store i8* %5, i8** %13
store i64 %6, i64* %14
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%23 = load i8*, i8** %8
%24 = call i32 @strncpy(i8* %22, i8* %23, i64 255)
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%26 = call i8* @strtok(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %26, i8** %16
%27 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %17
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %18
%29 = load i8*, i8** %16
%30 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%31 = icmp ne i8* %29, %30
br i1 %31, label %32, label %43
32: ; preds = %7
%33 = load i8*, i8** %16
%34 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = icmp ugt i8* %33, %35
br i1 %36, label %37, label %39
37: ; preds = %32
store i8* null, i8** %19
store i8* null, i8** %20
%38 = load i8*, i8** %16
store i8* %38, i8** %21
br label %42
39: ; preds = %32
store i8* null, i8** %19
%40 = load i8*, i8** %16
store i8* %40, i8** %20
%41 = load i8*, i8** %17
store i8* %41, i8** %21
br label %42
42: ; preds = %39, %37
br label %60
43: ; preds = %7
%44 = load i8*, i8** %17
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %15, i64 0, i64 0
%46 = load i8*, i8** %16
%47 = call i32 @strlen(i8* %46)
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = icmp ugt i8* %44, %50
br i1 %51, label %52, label %55
52: ; preds = %43
%53 = load i8*, i8** %16
store i8* %53, i8** %19
store i8* null, i8** %20
%54 = load i8*, i8** %17
store i8* %54, i8** %21
br label %59
55: ; preds = %43
%56 = load i8*, i8** %16
store i8* %56, i8** %19
%57 = load i8*, i8** %17
store i8* %57, i8** %20
%58 = load i8*, i8** %18
store i8* %58, i8** %21
br label %59
59: ; preds = %55, %52
br label %60
60: ; preds = %59, %42
br label %61
61: ; preds = %60
%62 = load i8*, i8** %9
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %79
64: ; preds = %61
%65 = load i64, i64* %10
%66 = icmp ugt i64 %65, 0
br i1 %66, label %67, label %79
67: ; preds = %64
%68 = load i8*, i8** %19
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %75
70: ; preds = %67
%71 = load i8*, i8** %9
%72 = load i8*, i8** %19
%73 = load i64, i64* %10
%74 = call i32 @strncpy(i8* %71, i8* %72, i64 %73)
br label %78
75: ; preds = %67
%76 = load i8*, i8** %9
%77 = getelementptr inbounds i8, i8* %76, i64 0
store i8 0, i8* %77
br label %78
78: ; preds = %75, %70
br label %79
79: ; preds = %78, %64, %61
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
%82 = load i8*, i8** %11
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %99
84: ; preds = %81
%85 = load i64, i64* %12
%86 = icmp ugt i64 %85, 0
br i1 %86, label %87, label %99
87: ; preds = %84
%88 = load i8*, i8** %20
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %95
90: ; preds = %87
%91 = load i8*, i8** %11
%92 = load i8*, i8** %20
%93 = load i64, i64* %12
%94 = call i32 @strncpy(i8* %91, i8* %92, i64 %93)
br label %98
95: ; preds = %87
%96 = load i8*, i8** %11
%97 = getelementptr inbounds i8, i8* %96, i64 0
store i8 0, i8* %97
br label %98
98: ; preds = %95, %90
br label %99
99: ; preds = %98, %84, %81
br label %100
100: ; preds = %99
br label %101
101: ; preds = %100
%102 = load i8*, i8** %13
%103 = icmp ne i8* %102, null
br i1 %103, label %104, label %119
104: ; preds = %101
%105 = load i64, i64* %14
%106 = icmp ugt i64 %105, 0
br i1 %106, label %107, label %119
107: ; preds = %104
%108 = load i8*, i8** %21
%109 = icmp ne i8* %108, null
br i1 %109, label %110, label %115
110: ; preds = %107
%111 = load i8*, i8** %13
%112 = load i8*, i8** %21
%113 = load i64, i64* %14
%114 = call i32 @strncpy(i8* %111, i8* %112, i64 %113)
br label %118
115: ; preds = %107
%116 = load i8*, i8** %13
%117 = getelementptr inbounds i8, i8* %116, i64 0
store i8 0, i8* %117
br label %118
118: ; preds = %115, %110
br label %119
119: ; preds = %118, %104, %101
br label %120
120: ; preds = %119
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define void @get_led_info(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4, i8* %5, i64 %6) {
%8 = alloca [255 x i8]
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%10 = call i32 @strncpy(i8* %9, i8* %0, i64 255)
%11 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %11, %9
br i1 %14, label %15, label %26
15: ; preds = %7
%16 = call i32 @strlen(i8* %9)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 %17
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = icmp ugt i8* %12, %19
%21 = select i1 %20, i8* null, i8* %12
%22 = select i1 %20, i8* %12, i8* %13
%23 = icmp ne i8* %1, null
%24 = icmp ne i64 %2, 0
%25 = and i1 %23, %24
br i1 %25, label %34, label %37
26: ; preds = %7
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 1
%28 = icmp ugt i8* %11, %27
%29 = select i1 %28, i8* null, i8* %11
%30 = select i1 %28, i8* %11, i8* %12
%31 = icmp ne i8* %1, null
%32 = icmp ne i64 %2, 0
%33 = and i1 %31, %32
br i1 %33, label %36, label %37
34: ; preds = %15
%35 = call i32 @strncpy(i8* %1, i8* %9, i64 %2)
br label %37
36: ; preds = %26
store i8 0, i8* %1
br label %37
37: ; preds = %26, %15, %36, %34
%38 = phi i8* [ %30, %26 ], [ %22, %15 ], [ %30, %36 ], [ %22, %34 ]
%39 = phi i8* [ %29, %26 ], [ %21, %15 ], [ %29, %36 ], [ %21, %34 ]
%40 = icmp ne i8* %3, null
%41 = icmp ne i64 %4, 0
%42 = and i1 %40, %41
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = icmp eq i8* %39, null
br i1 %44, label %47, label %45
45: ; preds = %43
%46 = call i32 @strncpy(i8* %3, i8* %39, i64 %4)
br label %48
47: ; preds = %43
store i8 0, i8* %3
br label %48
48: ; preds = %37, %47, %45
%49 = icmp ne i8* %5, null
%50 = icmp ne i64 %6, 0
%51 = and i1 %49, %50
br i1 %51, label %52, label %57
52: ; preds = %48
%53 = icmp eq i8* %38, null
br i1 %53, label %56, label %54
54: ; preds = %52
%55 = call i32 @strncpy(i8* %5, i8* %38, i64 %6)
br label %57
56: ; preds = %52
store i8 0, i8* %5
br label %57
57: ; preds = %54, %56, %48
ret void
}