#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
scalar_t__ strcmp(char const *, char *);
char *strdup(char const *);
char *strsep(char **, char *);
void update_nextconf(const char *val, char *next_settings) {
  char *work = strdup(val);
  char *free_work = work;
  char *dev = strsep(&work, ":");
  char *fstype = strsep(&work, ":");
  char *file = strsep(&work, ":");
  if (strcmp(val, "-") == 0) {
  } else if (dev && fstype && file && *dev && *fstype && *file) {
    snprintf(next_settings, 421, "%s", val);
  } else {
    printf("Bad next_settings '%s': should be for example "
           "'mmcblk0p1:vfat:flipflop.txt'\n",
           val);
  }
  free(free_work);
}


x86 assembly (clang, -O0):
<update_nextconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x30(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1070 <strsep@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11e0 <update_nextconf+0x80>
jmp    1264 <update_nextconf+0x104>
cmpq   $0x0,-0x28(%rbp)
je     124f <update_nextconf+0xef>
cmpq   $0x0,-0x30(%rbp)
je     124f <update_nextconf+0xef>
cmpq   $0x0,-0x38(%rbp)
je     124f <update_nextconf+0xef>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124f <update_nextconf+0xef>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124f <update_nextconf+0xef>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     124f <update_nextconf+0xef>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1a5,%esi
lea    0xdbf(%rip),%rdx
call   1050 <snprintf@plt>
jmp    125f <update_nextconf+0xff>
mov    -0x8(%rbp),%rsi
lea    0xdad(%rip),%rdi
call   1040 <printf@plt>
jmp    1264 <update_nextconf+0x104>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_nextconf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
call   1080 <strdup@plt>
mov    %rax,%r14
mov    %rax,0x10(%rsp)
lea    0xe76(%rip),%rbp
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strsep@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strsep@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %rbp,%rsi
call   1070 <strsep@plt>
mov    %rax,%rbp
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     121a <update_nextconf+0xba>
test   %r12,%r12
je     120b <update_nextconf+0xab>
test   %r13,%r13
je     120b <update_nextconf+0xab>
test   %rbp,%rbp
je     120b <update_nextconf+0xab>
cmpb   $0x0,(%r12)
je     120b <update_nextconf+0xab>
cmpb   $0x0,0x0(%r13)
je     120b <update_nextconf+0xab>
cmpb   $0x0,0x0(%rbp)
je     120b <update_nextconf+0xab>
lea    0xe0d(%rip),%rdx
mov    0x8(%rsp),%rdi
mov    $0x1a5,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
jmp    121a <update_nextconf+0xba>
lea    0xdf5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [77 x i8] c"Bad next_settings '%s': should be for example 'mmcblk0p1:vfat:flipflop.txt'\0A\00"
define void @update_nextconf(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %3
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
store i8* %12, i8** %6
%13 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %7
%14 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %8
%15 = call i8* @strsep(i8** %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %9
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
br label %52
20: ; preds = %2
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %48
23: ; preds = %20
%24 = load i8*, i8** %8
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %48
26: ; preds = %23
%27 = load i8*, i8** %9
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %48
34: ; preds = %29
%35 = load i8*, i8** %8
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %34
%40 = load i8*, i8** %9
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %39
%45 = load i8*, i8** %4
%46 = load i8*, i8** %3
%47 = call i32 @snprintf(i8* %45, i32 421, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %46)
br label %51
48: ; preds = %39, %34, %29, %26, %23, %20
%49 = load i8*, i8** %3
%50 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %44
br label %52
52: ; preds = %51, %19
%53 = load i8*, i8** %6
%54 = call i32 @free(i8* %53)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [77 x i8] c"Bad next_settings '%s': should be for example 'mmcblk0p1:vfat:flipflop.txt'\0A\00"
define void @update_nextconf(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @strdup(i8* %0)
store i8* %5, i8** %3
%6 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %30, label %11
11: ; preds = %2
%12 = icmp ne i8* %6, null
%13 = icmp ne i8* %7, null
%14 = select i1 %12, i1 %13, i1 false
%15 = icmp ne i8* %8, null
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %28
17: ; preds = %11
%18 = load i8, i8* %6
%19 = icmp eq i8 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %17
%21 = load i8, i8* %7
%22 = icmp eq i8 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = load i8, i8* %8
%25 = icmp eq i8 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @snprintf(i8* %1, i32 421, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %30
28: ; preds = %23, %20, %17, %11
%29 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %30
30: ; preds = %26, %28, %2
%31 = call i32 @free(i8* %5)
ret void
}