#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  char *s = "c101,c22,c3,c4";
  char *p = s;
  char *tp = s;
  char temp[5];
  int ucnt = 0;
  int l = strlen(s);
  int i, c = 0;
  for (i = 0; i < l; i++) {
    if (s[i] == ',') {
      tp = &s[i - 1];
      ucnt = tp - p + 1;
      printf("ucnt %d\n", ucnt);
      memset(temp, 0, 5);
      strncpy(temp, p, ucnt);
      printf("t %s\n", temp);
      sscanf(temp, "c%d", &c);
      printf("c %d\n", c);
      p = &s[i + 1];
      continue;
    }
    if (i == l - 1 && s[i] != ',') {
      tp = &s[i];
      ucnt = tp - p + 1;
      printf("ucnt %d\n", ucnt);
      memset(temp, 0, 5);
      strncpy(temp, p, ucnt);
      printf("t %s\n", temp);
      sscanf(temp, "c%d", &c);
      printf("c %d\n", c);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1325 <main+0x1d5>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
jne    1263 <main+0x113>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <memset@plt>
lea    -0x25(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x25(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xdee(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x38(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1317 <main+0x1c7>
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1312 <main+0x1c2>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2c,%eax
je     1312 <main+0x1c2>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <memset@plt>
lea    -0x25(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x25(%rbp),%rsi
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x25(%rbp),%rdi
lea    0xd26(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1070 <sscanf@plt>
mov    -0x38(%rbp),%esi
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1317 <main+0x1c7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119b <main+0x4b>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
movl   $0x0,0x4(%rsp)
test   %eax,%eax
jle    12b4 <main+0x164>
lea    -0x1(%rax),%ebx
mov    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x13(%rsp),%r14
xor    %r12d,%r12d
mov    %rbp,%r15
jmp    1223 <main+0xd3>
nopw   0x0(%rax,%rax,1)
lea    (%r12,%rbp,1),%r13
sub    %r15d,%r13d
lea    0xe61(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
lea    0xe3c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xe2e(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
mov    0x4(%rsp),%esi
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%r12,%rbp,1),%r15
add    $0x1,%r15
add    $0x1,%r12
cmp    %r12,0x8(%rsp)
je     12b4 <main+0x164>
mov    $0x910,%eax
bt     %r12,%rax
jb     11a0 <main+0x50>
cmp    %r12,%rbx
jne    1214 <main+0xc4>
mov    %rbx,%r13
mov    %rbp,%rbx
add    %r12d,%ebp
sub    %r15d,%ebp
add    $0x1,%ebp
lea    0xdc2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1060 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %rbx,%rbp
mov    %r13,%rbx
call   1030 <strncpy@plt>
lea    0xd99(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xd8b(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
mov    0x4(%rsp),%esi
lea    0xd7a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1214 <main+0xc4>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"c101,c22,c3,c4\00"
@.str.1 = [9 x i8] c"ucnt %d\0A\00"
@.str.2 = [6 x i8] c"t %s\0A\00"
@.str.3 = [4 x i8] c"c%d\00"
@.str.4 = [6 x i8] c"c %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %2
%10 = load i8*, i8** %2
store i8* %10, i8** %3
%11 = load i8*, i8** %2
store i8* %11, i8** %4
store i32 0, i32* %6
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
store i32 0, i32* %9
store i32 0, i32* %8
br label %14
14: ; preds = %98, %0
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %101
18: ; preds = %14
%19 = load i8*, i8** %2
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 44
br i1 %25, label %26, label %58
26: ; preds = %18
%27 = load i8*, i8** %2
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8* %31, i8** %4
%32 = load i8*, i8** %4
%33 = load i8*, i8** %3
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = add nsw i64 %36, 1
%38 = trunc i64 %37 to i32
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%42 = call i32 @memset(i8* %41, i32 0, i32 5)
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%44 = load i8*, i8** %3
%45 = load i32, i32* %6
%46 = call i32 @strncpy(i8* %43, i8* %44, i32 %45)
%47 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%51 = load i32, i32* %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %51)
%53 = load i8*, i8** %2
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
store i8* %57, i8** %3
br label %98
58: ; preds = %18
%59 = load i32, i32* %8
%60 = load i32, i32* %7
%61 = sub nsw i32 %60, 1
%62 = icmp eq i32 %59, %61
br i1 %62, label %63, label %97
63: ; preds = %58
%64 = load i8*, i8** %2
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 44
br i1 %70, label %71, label %97
71: ; preds = %63
%72 = load i8*, i8** %2
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8* %75, i8** %4
%76 = load i8*, i8** %4
%77 = load i8*, i8** %3
%78 = ptrtoint i8* %76 to i64
%79 = ptrtoint i8* %77 to i64
%80 = sub i64 %78, %79
%81 = add nsw i64 %80, 1
%82 = trunc i64 %81 to i32
store i32 %82, i32* %6
%83 = load i32, i32* %6
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%86 = call i32 @memset(i8* %85, i32 0, i32 5)
%87 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%88 = load i8*, i8** %3
%89 = load i32, i32* %6
%90 = call i32 @strncpy(i8* %87, i8* %88, i32 %89)
%91 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %91)
%93 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%94 = call i32 @sscanf(i8* %93, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%95 = load i32, i32* %9
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %71, %63, %58
br label %98
98: ; preds = %97, %26
%99 = load i32, i32* %8
%100 = add nsw i32 %99, 1
store i32 %100, i32* %8
br label %14
101: ; preds = %14
%102 = load i32, i32* %1
ret i32 %102
}

LLVM IR (-O2):
@.str = [15 x i8] c"c101,c22,c3,c4\00"
@.str.1 = [9 x i8] c"ucnt %d\0A\00"
@.str.2 = [6 x i8] c"t %s\0A\00"
@.str.3 = [4 x i8] c"c%d\00"
@.str.4 = [6 x i8] c"c %d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %54
7: ; preds = %0
%8 = add nsw i32 %4, -1
%9 = zext i32 %8 to i64
%10 = zext i32 %4 to i64
br label %11
11: ; preds = %7, %50
%12 = phi i64 [ 0, %7 ], [ %52, %50 ]
%13 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %7 ], [ %51, %50 ]
%14 = getelementptr inbounds [15 x i8], [15 x i8]* @.str, i64 0, i64 %12
%15 = lshr i64 2320, %12
%16 = and i64 %15, 1
%17 = icmp eq i64 %16, 0
br i1 %17, label %35, label %18
18: ; preds = %11
%19 = add nsw i64 %12, -1
%20 = getelementptr inbounds [15 x i8], [15 x i8]* @.str, i64 0, i64 %19
%21 = ptrtoint i8* %20 to i64
%22 = ptrtoint i8* %13 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = add i32 %24, 1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = call i32 @memset(i8* %3, i32 0, i32 5)
%28 = call i32 @strncpy(i8* %3, i8* %13, i32 %25)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%30 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%31 = load i32, i32* %2
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = add nuw nsw i64 %12, 1
%34 = getelementptr inbounds [15 x i8], [15 x i8]* @.str, i64 0, i64 %33
br label %50
35: ; preds = %11
%36 = icmp eq i64 %12, %9
br i1 %36, label %37, label %50
37: ; preds = %35
%38 = ptrtoint i8* %14 to i64
%39 = ptrtoint i8* %13 to i64
%40 = sub i64 %38, %39
%41 = trunc i64 %40 to i32
%42 = add i32 %41, 1
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = call i32 @memset(i8* %3, i32 0, i32 5)
%45 = call i32 @strncpy(i8* %3, i8* %13, i32 %42)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%47 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%48 = load i32, i32* %2
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %35, %37, %18
%51 = phi i8* [ %34, %18 ], [ %13, %37 ], [ %13, %35 ]
%52 = add nuw nsw i64 %12, 1
%53 = icmp eq i64 %52, %10
br i1 %53, label %54, label %11
54: ; preds = %50, %0
ret i32 0
}